RegExp: problems with comma-seperated string
With New RegExp
.Pattern = "^\d+(?:,\d+)*$"
For Each TestString in Array("0,11,2",",3","4,","5,,6","789")
WScript.Echo TestString & vbTab & .Test(TestString)
Next
End With
--
There are no passengers on spaceship earth. We are all crew.
-Marshall McLuhan
=-=-=
Steve
-=-=-
Quote:
> Hi,
> I need a regexp that will test a string given by a user. The string must be
> a comma seperated string - in other words like
> 54,454,343,576,0,34
> with no leading or trailing commas.
> But how do I do it ?
> Specifically I have problems with figuring out how to specify, that I would
> like a number of occurences of the combination
> one or more [0..9]
> and then zero or more
> one ,
> one or more [0..9]
> The best shot at a regexp I have written for this is
> \d+[,\d+]*
> The explanation is:
> One or more digits
> zero or more of the sequence
> a comma
> one or more digits
> ... but it doesn't seem correct ... :(
> Can you guys help me with this ?