Click here to Skip to main content
15,041,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I was wondering how to create a regex code that would look for a specific word followed by a space then a nonspecific number.

Anyone have any ideas?

Thanks in advance!
Posted

The solution suggested by Anil seems good to me.

I would also like to add that you can use regular expression building tool to learn and create regular expressions. One such good tool is here on CodeProject:
Expresso - A Tool for Building and Testing Regular Expressions[^]
   
Something like this i assume?
This will match for strings those start with "word" then followed by AT LEAST one space and then AT LEAST one number.
Regex reg = new Regex("word\\s+[0-9]+");

You can remove +'s if you only need one space or one number and that is a must. You can use *'s instead of +'s if you want them to occur zero or more times.

Regards,
Anıl Yıldız.
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900