
tanker
Novice
Mar 22, 2017, 11:04 AM
Post #1 of 5
(15925 views)
|
RegExp that is giving me fits
|
Can't Post
|
|
I have spent the past couple days trying to get an expression to work and I am definitely missing something. I'm a mid level Perl user. Source line examples:
<I32>SLEEVE (USE WITH INDEX 2) <I31>SPACER, SLEEVE (UNDER BOLT HEAD) (USE WITH INDEX 73) What I expect to get:
(USE WITH INDEX 2) (UNDER BOLT HEAD) (USE WITH INDEX 73) What I'm getting:
(USE WITH INDEX 2) (USE WITH INDEX 73) My current attempt is the following.
$XYZ =~ s/^(.*)\((.*)\)$/\($2\)/; I'm trying to capture the notes between the first "(" and the last ")". For some reason I can't get it to keep the first "(...)" in this case. In my current attempt I try to match the beginning of the line followed by any characters up to ( then match any text up to a ) at the end of the string. Then output the contents of the 2nd wildcard between ( ). The way I have written it, I'm thinking (obviously incorrectly) it should even catch (...) (...) (...) I know it's going to probably be something simple but putting it aside to think about other things, hoping it comes to me, isn't working. Thanks in advance, Stan
|