The stupid question is the question not asked | |
PerlMonks |
Re: data between bracketsby ww (Archbishop) |
on Dec 06, 2007 at 22:25 UTC ( [id://655541]=note: print w/replies, xml ) | Need Help?? |
Your regex, $value =~ /^.*\(.*)\)/; fails because you have an an unmatched closing parenthesis in the regex. Attempting to execute a short version of what may be your code,
produces this: Unmatched ) in regex; marked by <-- HERE in m/^.*\(.*) <-- HERE \)/ at .... In other words, the regex engine balks when it finds a special character, the closing paren, unescaped, when it did not find an opening paren. When you receive a message of that sort, it's valuable to those who would assist you, so it is well to include it in your post. However, dealing only with the unmatched paren doesn't give you what you sought. So, extending/explaining sh1tn's correct answer of s/.+?\((.+?)\).*/$1/;
You'll find more in the tutorial section, under Tutorials#Pattern-Matching-and-Regular-Expressions and while you may find Friedl's "Mastering Regular Expressions" more than you seek right now, but it's well worth the study.
In Section
Seekers of Perl Wisdom
|
|