ydbn

123ABC123 => 123ABC, 123
343BBB => 343BBB, null
12323 => null, 12322

( <first>.*\D+)( <second>\d*) doesn't work on the third line.


Re: Regular Expressions Regular express question

Thomas Danecker

You have to make the first group optional! I'd also change the second group:

Code Snippet

( <first>.*\D+) ( <second>\d+)






Re: Regular Expressions Regular express question

Soe Moe

Hi, here is the regex

^( <first>\d+[a-zA-Z]+) ( <second>\d*)$

and test

private void Test()
{
  string regex = @"^( <first>\d+[a-zA-Z]+) ( <second>\d*)$";
  Regex reg = new Regex(regex, RegexOptions.Multiline);
}