in reply to quote regular expression

I think you should handle the greater than three characters constraint outside of the regular expression. Also, can you assume that an escaped single quote will only occur within a single quoted string? If so, the regex becomes very straight-forward:
while ($text =~ m/'(((\\')|[^'])*)'/g) { if (length($1) > 3) { ...do something... } }
The thing about the short string constraint is that you still want the regex engine to match and move past them even though you're not interested in processing them. That suggests you should perform the length check outside of the regex.

Also, do you have to handle \\? If so, just modify the regex as follows:

while ($text =~ m/'(((\\['\\])|[^'])*)'/g) {

Replies are listed 'Best First'.
Re^2: quote regular expression
by sadfaceman (Novice) on Jun 02, 2008 at 17:44 UTC
    that worked! thank you so much