Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Regular expression help needed

Reply
Thread Tools

Regular expression help needed

 
 
Peter Vanderhaden
Guest
Posts: n/a
 
      10-03-2007
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-forum.com/.

 
Reply With Quote
 
 
 
 
Sebastian Hungerecker
Guest
Posts: n/a
 
      10-03-2007
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: http://www.velocityreviews.com/forums/(E-Mail Removed)
ICQ: 205544826

 
Reply With Quote
 
 
 
 
Peter Vanderhaden
Guest
Posts: n/a
 
      10-03-2007
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-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression - Help needed ragz_82 Java 1 08-04-2009 07:59 AM
Regular expression - help needed Chanchal Java 1 12-13-2005 07:24 AM
quick help needed on regular expression validator David Cho ASP .Net 4 02-15-2005 09:47 AM
Help needed: cryptic perl regular expression in python syntax pekka niiranen Python 5 10-20-2004 12:39 PM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments