in reply to using substitution and pattern matching

When you use a regular expression (or substitution regular expression) to deal with quoted material, you run into problems with balanced quotes.

Of course you can hope that the embedded apostrophes have been properly escaped, and of course they should be if they're embedded within single-quoted material. But the point is that things just get a little too complicated when dealing with balanced quotes using simple regular expressions.

It is for this reason that people often suggest the module Text::Balanced. It can find balanced quoted text within a string. You can use it as a tool to help you rebuild the string with your new style of quotes.

If you do like using regular expressions though, you might benefit from use Regexp::Common qw/balanced/;.


Dave

  • Comment on Re: using substitution and pattern matching