Need some Regex help, please.
I'm trying to figure out the correct way of using Regex to filter a String so that it's in this format exactly:
I've looked online through some documentation and I can't seem to get it working correctly. This is what I have so far and have tested:
I'm not sure why it does not work from what I read. However, I don't know much about Regex's and am probably making this more difficult than it is. Any help is appreciated, thank you.
EDIT: I have the String one working, however I now need to allow the String to have whitespace in it:
EDIT 2: After realizing the user will probably have an unassertive amount of spaces, I have come to the conclusion that this works best:
Re: Need some Regex help, please.
Often I find it helps to break down the expression and concentrate on subsets of the overall goal. In your case, you could concentrate on the first string portion and try to match 'string'. There are different ways to match a word, you could try
[a-z]+//assuming the engine is set to case insensitive
Next, how would you add the number to this regex?