[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Regular expression help needed

Peter Vanderhaden

10/3/2007 5:39:00 PM

I'm trying to write a regular expression for a ruby program. What it
needs to match is:

0,,\a where 0 is any digit, then 2 commas, a backslash, then any
letter.

I have one that works if the expression didn't have the backslash (which
isn't an escape character, but a literal character):

if $inrec =~ /[[:digit:]],,[[:alpha:]]/

I've tried

if $inrec =~ /[[:digit:]],,\\[[:alpha:]]/

and

if $inrec =~ /[[:digit:]],,\[[:alpha:]]/

but neither works. Any ideas would be appreciated!
--
Posted via http://www.ruby-....

2 Answers

Sebastian Hungerecker

10/3/2007 5:53:00 PM

0

Peter Vanderhaden wrote:
> I'm trying to write a regular expression for a ruby program. What it
> needs to match is:
>
> 0,,\a where 0 is any digit, then 2 commas, a backslash, then any
> letter.
> ...
> I've tried
>
> if $inrec =~ /[[:digit:]],,\\[[:alpha:]]/
> ...
> but neither works.

Works here.

>> puts "Works!" if '0,,\a' =~ /[[:digit:]],,\\[[:alpha:]]/
Works!


--
NP: My Dying Bride - Two Winters Only
Jabber: sepp2k@jabber.org
ICQ: 205544826

Peter Vanderhaden

10/3/2007 6:07:00 PM

0

Sebastian, right you are! I must have made a typo. Sorry about that!

Sebastian Hungerecker wrote:
> Peter Vanderhaden wrote:
>> but neither works.
> Works here.
>
>>> puts "Works!" if '0,,\a' =~ /[[:digit:]],,\\[[:alpha:]]/
> Works!

--
Posted via http://www.ruby-....