中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 14:58
47,811 topics / 349,897 posts / today 0 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » How to extract the numbers from the combination of <letters + numbers>
Printable Version  3,914 / 18
Floor1 mouzeming Posted 2006-12-28 04:59
初级用户 Posts 28 Credits 66
Combination of letters and numbers.. For example, home001
How can I extract 001
Both letters and numbers are of unlimited length.
I don't know if batch processing can achieve it.
Hope experts can give guidance. No relevant information was found in the forum
Floor2 namejm Posted 2006-12-28 06:12
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Can numbers and letters possibly be mixed? Or are numbers one segment and letters another segment?
Floor3 everest79 Posted 2006-12-28 06:19
金牌会员 Posts 1,127 Credits 2,564
I have seen one case where a dictionary is needed

setlocal enabledelayedexpansion
set /p a=..
set b=%a%
for /f %%i in (dict.txt) do set b=!b:%%i=!
Can't remember clearly
Floor4 mouzeming Posted 2006-12-28 06:28
初级用户 Posts 28 Credits 66
Originally posted by namejm at 2006-12-28 06:12 AM:
  Can numbers and letters be mixed? Or are numbers one segment and letters another segment?

Yes. The front is letters. The back is numbers.
This is fixed.
Floor5 9527 Posted 2006-12-28 06:33
银牌会员 Posts 438 Credits 1,185 From 北京
No matter whether your numbers and text are mixed, do it all, heh heh......
No special symbols were tested

But I feel this code is a bit bloated
[ Last edited by 9527 on 2006-12-28 at 06:34 AM ]
Floor6 tao0610 Posted 2006-12-28 06:35
高级用户 Posts 218 Credits 579
Just replace the letters directly without any modification!
Floor7 redtek Posted 2006-12-28 06:36
金牌会员 Posts 1,147 Credits 2,902
Wonderful!!! Appreciate ~~~
Floor8 vkill Posted 2006-12-28 06:41
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
set "var=abc123 &^*"
echo "%var%"|sed "s/^\x22//;s/\x22$//;s/[a-z]//g"
Floor9 namejm Posted 2006-12-28 07:08
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Hehe, actually I just want to ask the original poster whether it's only to intercept a specified segment of numbers or to extract all numbers in the string. If it's just to extract all numbers, then it's much easier, just replace the letters with empty values. But it seems the original poster's intention is not like that.
Floor10 9527 Posted 2006-12-28 08:29
银牌会员 Posts 438 Credits 1,185 From 北京
Then please, moderator namejm, release the code that the original poster needs, so that we juniors can also learn more...
Floor11 zh159 Posted 2006-12-28 08:36
金牌会员 Posts 1,467 Credits 3,687
Originally posted by mouzeming at 2006-12-27 17:28:

Yes. The front is letters. The back is numbers.
This is fixed.

According to the original poster's statement, the data has letters in the front and numbers in the back, which is fixed, so moderator namejm doesn't need to worry about mixing letters and numbers

Floor12 mouzeming Posted 2006-12-28 11:28
初级用户 Posts 28 Credits 66
Thank you everyone.. I'll try it at the company tomorrow..

b=%b%%aa:~0,1%

set "var=abc123 &^*"
echo "%var%"|sed "s/^\x22//;s/\x22$//;s/[a-z]//g"

set var=%%var:%%n=%%
Floor13 zh159 Posted 2006-12-28 11:46
金牌会员 Posts 1,467 Credits 3,687
The person on floor 8 needs the "sed" software.
Floor14 redtek Posted 2006-12-28 11:57
金牌会员 Posts 1,147 Credits 2,902
Top~ Appreciate ~~~!!!
Floor15 jmz573515 Posted 2006-12-28 21:59
银牌会员 Posts 464 Credits 1,212
There is an idea, I don't know if this method can be used when entering the password?
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023