China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 03:45
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » New space deletion problem?? View 2,469 Replies 40
Floor 31 Posted 2008-05-29 23:04 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline

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 ]
致精致简!
Floor 32 Posted 2008-05-29 23:18 ·  中国 重庆 电信
初级用户
★★
Credits 198
Posts 89
Joined 2007-09-06 23:22
18-year member
UID 96746
Gender Male
From 重庆
Status Offline
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?
Floor 33 Posted 2008-05-29 23:21 ·  中国 上海 电信
中级用户
★★
Credits 206
Posts 93
Joined 2007-08-16 17:19
18-year member
UID 95263
Gender Male
Status Offline
Why does the empty line of [ not become empty anymore? It only deletes the ; and all spaces.
@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
)
Floor 34 Posted 2008-05-29 23:24 ·  中国 上海 电信
中级用户
★★
Credits 206
Posts 93
Joined 2007-08-16 17:19
18-year member
UID 95263
Gender Male
Status Offline
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.
Floor 35 Posted 2008-05-29 23:28 ·  中国 重庆 电信
初级用户
★★
Credits 198
Posts 89
Joined 2007-09-06 23:22
18-year member
UID 96746
Gender Male
From 重庆
Status Offline
Adding or not adding .* both match [reg]add. Because .* can be nothing, but ..* means there must be at least one character.
Floor 36 Posted 2008-05-29 23:34 ·  中国 上海 电信
中级用户
★★
Credits 206
Posts 93
Joined 2007-08-16 17:19
18-year member
UID 95263
Gender Male
Status Offline
Hope brother 26933062 gives another complete code

[ ; Also, there are spaces in front of each line of characters, and all other spaces except [ are deleted ...............
Floor 37 Posted 2008-05-29 23:36 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
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.
致精致简!
Floor 38 Posted 2008-05-30 13:51 ·  中国 辽宁 本溪 中移铁通
中级用户
★★
Credits 206
Posts 93
Joined 2007-08-16 17:19
18-year member
UID 95263
Gender Male
Status Offline
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?
Floor 39 Posted 2008-05-31 12:21 ·  中国 重庆 合川区 电信
初级用户
★★
Credits 198
Posts 89
Joined 2007-09-06 23:22
18-year member
UID 96746
Gender Male
From 重庆
Status Offline
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........
Floor 40 Posted 2008-05-31 12:52 ·  中国 辽宁 营口 中移铁通
中级用户
★★
Credits 206
Posts 93
Joined 2007-08-16 17:19
18-year member
UID 95263
Gender Male
Status Offline
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
Floor 41 Posted 2008-05-31 13:29 ·  中国 北京 联通
社区乞丐
Credits -61
Posts 37
Joined 2008-04-19 17:10
18-year member
UID 116329
Gender Male
Status Offline
Trim left and right spaces:
3.txt

I am robert
what are you doing ???
oh,I teach batch

Test code:

@echo off&setlocal
echo. Before processing:
for /f "delims=" %%a in (3.txt) do echo.
echo After processing:
for /f "tokens=*" %%b in (3.txt) do call:FQ "%%b"
goto:eof
:FQ
echo
Forum Jump: