Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Regex group without capture

Reply
Thread Tools

Regex group without capture

 
 
S. Robert James
Guest
Posts: n/a
 
      02-22-2007
Is there a way to make a regex group without capturing the group (in
Perl I believe it's possible, can't find any docs how to do this in
Ruby)

 
Reply With Quote
 
 
 
 
Peņa, Botp
Guest
Posts: n/a
 
      02-22-2007
From: S. Robert James [(E-Mail Removed)] :
# Is there a way to make a regex group without capturing the group (in
# Perl I believe it's possible, can't find any docs how to do this in
# Ruby)

same, preprend "?:" , like (?:<expr_here>), where <expr_here> will not =
be captured

irb(main):006:0> "this is a test".scan /(this).*(test)/
=3D> [["this", "test"]]
irb(main):007:0> "this is a test".scan /(this).*(?:test)/
=3D> [["this"]]
irb(main):008:0> "this is a test".scan /(?:this).*(test)/
=3D> [["test"]]

kind regards -botp

 
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
Screen Capture With Mouse , Mouse Position Capture Max Java 7 08-08-2009 11:51 PM
xslt 2.0 regex iterate over captured substrings ==> regex-group(n) RolfK XML 1 06-07-2009 12:04 PM
python regex character group matches...group...gotcha christopher taylor Python 0 09-17-2008 03:31 PM
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
SuperVideoCap work as a broadcast capture and screen capture and record tool. hely0123 Media 0 10-30-2007 08:59 AM



Advertisments