Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Simple regex question

Reply
Thread Tools

Simple regex question

 
 
amirovic@googlemail.com
Guest
Posts: n/a
 
      02-25-2009
Hi,

I have a simple question but somehow I can't solve it myself:

my $var = "[ a a a a a a a a ]";

I'm working with Parse::Recdescent and would like to match this (it's
not about Parse::Recdescent but a general question):

rule: "[" /.*/ "]"

Now "/.*/" matches everything including the "]", but I'd like to match
every before "]". How should this be done?

Thanks a lot for any response,
Tom
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      02-25-2009
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>
> my $var = "[ a a a a a a a a ]";
>
> I'm working with Parse::Recdescent and would like to match this (it's
> not about Parse::Recdescent but a general question):
>
> rule: "[" /.*/ "]"
>
> Now "/.*/" matches everything including the "]", but I'd like to match
> every before "]". How should this be done?


$var =~ /\[(.*)]/;
print "\"$1\"\n";

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
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
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
Simple Python REGEX Question johnny Python 4 05-12-2007 09:38 PM
a simple regex question John Salerno Python 6 04-02-2006 02:55 PM
RegEx Woes! Please Help, Simple Question Saad Malik Java 5 05-02-2005 04:06 PM
(Maybe) a simple question about regex Sam Kong Ruby 8 03-25-2005 01:25 PM



Advertisments