I am trying to use a regex to get the value after a character. In this case, the string is m325 and I need to get whatever is after the m.
Can anybody tell me what is wrong with my code?
Regex rgMeter = new Regex("m(.+$");
intMeterID = Convert.ToInt32(rgMeter.Match(strID));
Update:
Thanks for all your answers…for some reason the regex “m(.+)$” is returning the m as well as the string I require. I have tried the Groups example and it returns the data that I want. Why do I need to use Groups to do this?
Apart from the missing
), you oversimplified it a bit. You need to do(Possibly, you might want to add a check if the
Match()matched or not.)