Simple regex question

A

amirovic

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
 
G

Gunnar Hjalmarsson

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";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top