|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
还有,再劳驾:为什么不在后面再加个 .* 形如:".*\.*" ,这样和不加有什么区别?
...
.*\ 只要符号条件就已经匹配了,所以不用管 后面是否还有内容
后面加.*意思是后面有或无内容都匹配。
但若是".*\..*" 就不一样了。表示后面至少还要有一个字符
回27楼: eol=;
Last edited by 26933062 on 2008-5-29 at 11:06 PM ]
Also, please trouble again: Why not add a .* at the end, in the form of ".*\.*", what is the difference between this and not adding it?
...
.*\ just matches if the conditions are met, so it doesn't matter if there is content after the
Adding .* after means it matches whether there is content after the or not.
But if it is ". *\..*", it's different. It means there must be at least one character after the
Reply to floor 27: eol=;
Last edited by 26933062 on 2008-5-29 at 11:06 PM ]
|

致精致简! |
|
2008-5-29 23:04 |
|
|
WANKOILZ
初级用户
 
积分 198
发帖 89
注册 2007-9-6 来自 重庆
状态 离线
|
『第 32 楼』:
使用 LLM 解释/回答一下
哦,就是,.*\[..*\] 只要符号条件就已经匹配了,想通了,非常感谢。
for /f 不是默认就忽略 ; 开头的行么。
Oh, that is, .*\ just needs to meet the conditions to match, I got it, thank you very much. Does for /f not ignore lines starting with ; by default?
|
|
2008-5-29 23:18 |
|
|
amio
中级用户
  
积分 206
发帖 93
注册 2007-8-16
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
这样输出 为什么 [ 的空行就不会空了呢 只会吧; 和全部的空格删除
@echo off
for /f "delims=:" %%a in ('findstr /n ".*\[..*\]" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
if defined .%%a echo.
for /f "tokens=*" %%i in ("%%b") do echo.%%i>>temp.txt
)
Why does the empty line of
" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
if defined .%%a echo.
for /f "tokens=*" %%i in ("%%b") do echo.%%i>>temp.txt
)
|
|
2008-5-29 23:21 |
|
|
amio
中级用户
  
积分 206
发帖 93
注册 2007-8-16
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
Originally posted by zqz0012005 at 2008-5-29 11:01 PM:
如果后面再加个 .*,则像add这样不是以]结尾的行也会匹配,而这样的行不是楼主想的要吧
侥幸吧 我修改的文件里 没有这些
Originally posted by zqz0012005 at 2008-5-29 11:01 PM:
If you add a .* later, then lines like add that don't end with ] will also be matched, and such lines are not what the楼主 wanted, right?
Lucky! There are no such things in the file I modified.
|
|
2008-5-29 23:24 |
|
|
WANKOILZ
初级用户
 
积分 198
发帖 89
注册 2007-9-6 来自 重庆
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
加不加 .* 都匹配[reg]add。因为.*可以是什么都没有,但..*就表示至少要有一个字符。
Adding or not adding .* both match add. Because .* can be nothing, but ..* means there must be at least one character.
|
|
2008-5-29 23:28 |
|
|
amio
中级用户
  
积分 206
发帖 93
注册 2007-8-16
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
希望 26933062 兄弟 在给一个完整的代码
[ ; 还有每行字符前面空格 以及除 [ 空格外 删除其他全部空格 。。。。。。。。。。。。。。。。。。。。。。。。。。。
Hope brother 26933062 gives another complete code
|
|
2008-5-29 23:34 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 37 楼』:
使用 LLM 解释/回答一下
Originally posted by amio at 2008-5-29 23:34:
希望 26933062 兄弟 在给一个完整的代码
你的变化太多,解决了一个又来一个,
况且 你楼上的 简语 我看不懂。
Originally posted by amio at 2008-5-29 23:34:
Hope brother 26933062 gives a complete code again.
Your changes are too many. You solve one and another comes.
Moreover, I can't understand the simplified language above you.
|

致精致简! |
|
2008-5-29 23:36 |
|
|
amio
中级用户
  
积分 206
发帖 93
注册 2007-8-16
状态 离线
|
『第 38 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-5-29 11:36 PM:
你的变化太多,解决了一个又来一个,
况且 你楼上的 简语 我看不懂。
@echo off
for /f "delims=:" %%a in ('findstr /n ".*\" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
if defined .%%a echo.
for /f "tokens=*" %%i in ("%%b") do echo.%%i
)
这个代码基本已经可以实现我说的了 如何输出 ?
Originally posted by 26933062 at 2008-5-29 11:36 PM:
You've changed too much, one problem solved and another comes up.
Moreover, I can't understand the previous Jianyu.
@echo off
for /f "delims=:" %%a in ('findstr /n ".*\" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
if defined .%%a echo.
for /f "tokens=*" %%i in ("%%b") do echo.%%i
)
This code basically already achieves what I said. How to output?
|
|
2008-5-30 13:51 |
|
|
WANKOILZ
初级用户
 
积分 198
发帖 89
注册 2007-9-6 来自 重庆
状态 离线
|
『第 39 楼』:
使用 LLM 解释/回答一下
回楼上,晕!!
@echo off
for /f "delims=:" %%a in ('findstr /n ".*\[..*\]" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
if defined .%%a echo.>>a.txt
for /f "tokens=*" %%i in ("%%b") do echo.%%i>>a.txt
)
在echo后面加个>>就行了........
Back to the upstairs, dizzy!!
@echo off
for /f "delims=:" %%a in ('findstr /n ".*\" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
if defined .%%a echo.>>a.txt
for /f "tokens=*" %%i in ("%%b") do echo.%%i>>a.txt
)
Just add >> after echo........
|
|
2008-5-31 12:21 |
|
|
amio
中级用户
  
积分 206
发帖 93
注册 2007-8-16
状态 离线
|
『第 40 楼』:
使用 LLM 解释/回答一下
Originally posted by WANKOILZ at 2008-5-31 12:21 PM:
回楼上,晕!!
@echo off
for /f "delims=:" %%a in ('findstr /n ".*\" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
...
我试过这样 有的功能不能都实现
Originally posted by WANKOILZ at 2008-5-31 12:21 PM:
Reply to the above, dizzy!!
@echo off
for /f "delims=:" %%a in ('findstr /n ".*\" a.txt') do set .%%a=a
for /f "tokens=1* delims=:" %%a in ('findstr /n .* a.txt') do (
...
I tried this, some functions can't be fully implemented
|
|
2008-5-31 12:52 |
|
|
FQ
社区乞丐
积分 -61
发帖 37
注册 2008-4-19
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
去掉左右空格:
3.txt
I am robert
what are you doing ???
oh,I teach batch
测试代码:
@echo off&setlocal
echo.处理之前:
for /f "delims=" %%a in (3.txt) do echo.
echo 处理之后:
for /f "tokens=*" %%b in (3.txt) do call:FQ "%%b"
goto:eof
:FQ
echo
Trim left and right spaces:
3.txt
[code]
I am robert
what are you doing ???
oh,I teach batch
[/code]
Test code:
[code]
@echo off&setlocal
echo. Before processing:
for /f "delims=" %%a in (3.txt) do echo.[%%a]
echo After processing:
for /f "tokens=*" %%b in (3.txt) do call:FQ "%%b"
goto:eof
:FQ
echo [%~n1]
[/code]
|
|
2008-5-31 13:29 |
|