Regexp problem

I’m trying to detect the string “0,0,0” ( that’s numeric comma numeric
comma numeric) which is a value returned by cdrecord -scanbus
for detecting CD-ROM drives attached to a Linux system.
I have tried numerous regexp expressions but cannot get that string to
be detected.

eg : “[0-9].[0-9],[0-9]”

I assume that the comma is causing the trouble but even using \ escape
( ,) does not solve the problem.

Help please, thanks

Brett S Hallett wrote:

I’m trying to detect the string “0,0,0” ( that’s numeric comma numeric
comma numeric) which is a value returned by cdrecord -scanbus
for detecting CD-ROM drives attached to a Linux system.
I have tried numerous regexp expressions but cannot get that string to
be detected.

eg : “[0-9].[0-9],[0-9]”

I assume that the comma is causing the trouble but even using \ escape (
,) does not solve the problem.

Help please, thanks

Your first “comma” there is a period, which would be ok except you’ve
escaped it to mean a literal “.” instead of its meta-char meaning of
“any character”.

/[0-9],[0-9],[0-9]/.match(“0,1,2”)

works for me.

Hi,

Brett S Hallett wrote:

eg : “[0-9].[0-9],[0-9]”

/[0-9],[0-9],[0-9]/.match(“0,1,2”)

Also, /\d,\d,\d/

Regards,

Bill

···

From: “Michael campbell” michael_s_campbell@yahoo.com

If your ‘numerics’ can be numbers larger then 0-9 then I’m going to add to
what Bill said:

/\d+,\d+,\d+/

This should allows one or more digits followed by a comma, followed by one
or more digits,
followed by a comma, followed by one more or digits.

HTH

-Zach

···

-----Original Message-----
From: Bill Kelly [mailto:billk@cts.com]
Sent: Thursday, October 16, 2003 9:04 PM
To: ruby-talk ML
Subject: Re: regexp problem

Hi,

From: “Michael campbell” michael_s_campbell@yahoo.com

Brett S Hallett wrote:

eg : “[0-9].[0-9],[0-9]”

/[0-9],[0-9],[0-9]/.match(“0,1,2”)

Also, /\d,\d,\d/

Regards,

Bill