
May 11th, 2009, 06:44 PM
|
|
|
|
A regex for two numbers separated by a space or comma
Hi, i would like to create a regex match for X Y coordinates.
X and Y can be positive or negative; decimal or integer.
They are separated by a space, comma, or tab.
This is what I have (code below), and it works, BUT the problem is that it allows more than two numbers.
For instance, 1,1 works, which is good, but 1,1,1,1,1,1 also works, which is bad.
I have the \b (boundary) tags on each side to signify the start and end of the string, but I guess its not working.
By the way, the programming language is VB.NET if that makes any difference. If you can help me, I will be most appreciative.
My code:
Code:
Dim strRegEx As String = "\b(-{0,1}\d*\.{0,1}\d+)[, \t](-{0,1}\d*\.{0,1}\d+)\b"
|