in reply to Regular expression to match an A=B type string needs help in storing matched parts of string

Your regex works fine, but you have $assigned_dir declared with my inside of a block, so you have a scoping issue. I like the fact that you're using negated character classes instead of a .* construct; it's much more efficient. However, the single quotes can be left bare, rather than in a character class:
/[^=]+[=]'([^']+)'/
As for your other question, you have the regexes reversed: it only prints one 'a' in the first regex. This is because your capturing parens are only capturing one 'a' and the multiplier is outside of the one character that it's capturing. In your second regex, the parens are capturing everything because the multiplier is inside.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.

  • Comment on (Ovid) RE: Regular expression to match an A=B type string needs help in storing matched parts of string
  • Download Code