tags:

views:

61

answers:

1

I have a regular expression that is getting some information from a string. I need the values on both sides of either a space or a nbsp. Problem is that I believe the only way I can specify either or is with groups and bar. Is there a more concise or readable way to do this? There has to be!

Using Regex in C#

Regex:

(\d)(?:(?:\s)|(?: ))(\d)

Matching:

5 6
5 6
+5  A: 

Those nested parentheses and ?: are unnecessary. This should be sufficient:

(\d)(?:\s| )(\d)
cletus