Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

String format

Hello,
How to remove all characters from a string and then add a prefix of 0 to the result.
example:
Str= HJY98
EXPECTED RESULT:

Str=098

Thanks
Avatar of Bill Prew
Bill Prew

SO does that mean you want to remove everything that isn't a number (0 through 9)?


»bp
If so then you can do:

str = System.Text.RegularExpressions.Regex.Replace(str, "\D", "")

Open in new window


»bp
SOLUTION
Avatar of Sam Jacobs
Sam Jacobs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RIAS

ASKER

Thanks experts!!!!