mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2005
Posts: 37
S
Scratch Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2005
Posts: 37
I want to strip everything except numbers from a string.

For example, a user enters:

123ABC!@456

I want my script to remove the letters 'ABC!@' and just return the numbers they entered. (123456)

How would I do this?

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
There's many ways.

$remove(123ABC!@456,A,B,C,!,@)

Is one way that returns 123456.

Joined: Jan 2005
Posts: 37
S
Scratch Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2005
Posts: 37
That would work, but the user is not always going to enter that combination of letters and numbers. There's no way to predict what a user is going to enter. I just used that as an example. So, I need an identifier or alias that can strip out everything except numbers.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Usage: $justnums(string)

alias justnums var %a, %b = $regsub($1,/\D/g,,%a) | return %a


Gone.

Link Copied to Clipboard