RegExp: problems with comma-seperated string 
Author Message
 RegExp: problems with comma-seperated string

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 ?

--
Jesper Stocholm
http://www.*-*-*.com/ (online again soon)
Exercise you right to free speach - use encryption to secure your
communication



Mon, 02 Aug 2004 19:50:31 GMT  
 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 ?



Mon, 02 Aug 2004 21:37:16 GMT  
 RegExp: problems with comma-seperated string

Quote:
> 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

thanks ... :)

--
Jesper Stocholm
http://stocholm.dk (online again soon)
Exercise you right to free speach - use encryption to secure your
communication



Wed, 04 Aug 2004 20:02:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Comma Seperated Values

2. importing comma seperated values (csv)

3. HELP:Datagrid editing on comma-seperated files.

4. How to create comma seperated value text file from an access table

5. Reading non comma seperated data from a file.

6. Inverted commas in INSERT and UPDATE strings

7. Comma in a string

8. How do get a particular value from a comma delimiter string

9. Parsing a comma delmited string

10. How to seperate MM/DD/YY into seperate fields in access

11. Splitting strings into seperate fields

12. Seperate Address string

 

 
Powered by phpBB® Forum Software