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-23 01:55
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to extract the numbers from the combination of <letters + numbers> View 3,745 Replies 18
Floor 16 Posted 2006-12-28 22:08 ·  中国 湖南 郴州 电信
初级用户
Credits 66
Posts 28
Joined 2006-11-01 04:54
19-year member
UID 69099
Gender Male
Status Offline
The problem comes again. I'm sorry,

The number is put forward. For example, the user inputs a001 & a100.

If it's a number like a001, I need to remove the preceding a00.

If it's a number like a100, I just need to remove a100. The above code can achieve this.

That is to say, there needs to be a judgment on the value input by the user. If the number after the letter is 0, don't take it. Take the number after 0. Like what I said above, for a001, I only take 1. But for other input a100, I need to take 100. This feels relatively difficult.
Floor 17 Posted 2006-12-29 02:31 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by jmz573515 at 2006-12-28 21:59:
Is there an idea, I wonder if this method can be used when entering the password?

Yes, it can
Floor 18 Posted 2006-12-31 00:03 ·  中国 河南 许昌 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by mouzeming at 2006-12-28 09:08:
Here comes the problem again. Sorry,
The number is put forward. For example, the user enters a001 & a100
If it is a number like a001, I need to remove the a00 in front..
If it is a number like a100, I only ...

@echo off
set "var=abc000123000"
for %%n in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do call set var=%%var:%%n=%%
:loop
if "%var:~0,1%" == "0" set var=%var:~1%&&goto loop
echo %var%
pause
Floor 19 Posted 2007-05-08 19:55 ·  中国 广东 中山 电信
初级用户
★★
Credits 127
Posts 62
Joined 2007-04-19 12:43
19-year member
UID 85744
Gender Male
Status Offline
@echo off
setlocal enabledelayedexpansion

set/p aa=Enter your text:

if not defined aa goto :eof
set number=

:loop
if not defined aa goto :e
echo %aa:~0,1%|findstr "[0-9]">nul&&set number=!number!%aa:~0,1%
set aa=%aa:~1%
goto loop
:e
echo !number!
pause
Forum Jump: