in reply to Regular expression problem

There's a bug in your first regexp: You're using ',*' when I think you meant to use '.*'

Another potential bug is the fact that you're relying on $1 without first checking to see if a match succeeded. Bad dog.

Regarding your question, you might successfully get your regexp to match less by using the non-greedy modifier on the quantifier.

$var =~ /onChange\=\"\[(.*?)\]\"/;

The '.*?' construct says to match as little as possible of any number of characters until the first ]" is reached.


Dave

Replies are listed 'Best First'.
Re^2: Regular expression problem
by jockel (Beadle) on Jun 09, 2004 at 08:26 UTC
    Aargh .. the ",*" was a typo,, it's not acctually in the code

    ".*?" worked! Thanks! ... I thought I'd already tried that,, but apperantly not!

    Thanks to Dave and EdwardG!
    /jocke