I need to get better at regular expressions with Perl.. I wrote a script that does 98% of what I need and screws up 2%. That screwed up 2% causes problems.
I am trying to replace a list of expressions with another list of expressions.. The easy part was to write a script that runs through the list. The hard part is getting the regular expressions to work correctly.
For example:
$currentline =~ s/ListItem1/ListItem5/gi; works fine..
But, in my list, I have a lot of items within items... like:
$currentline =~ s/ListItem1/ListItem5/gi;
$currentline =~ s/ListItem1_1/ListItem5_2/gi;
so the second line never runs because all the ListItem1_1's are changed to ListItem5_1 already
How would I tell the first line to skip 'ListItem1' if it is followed by an underscore and a number? I tried a few regular expressions tutorials and I am not quite following them.
I am trying to replace a list of expressions with another list of expressions.. The easy part was to write a script that runs through the list. The hard part is getting the regular expressions to work correctly.
For example:
$currentline =~ s/ListItem1/ListItem5/gi; works fine..
But, in my list, I have a lot of items within items... like:
$currentline =~ s/ListItem1/ListItem5/gi;
$currentline =~ s/ListItem1_1/ListItem5_2/gi;
so the second line never runs because all the ListItem1_1's are changed to ListItem5_1 already
How would I tell the first line to skip 'ListItem1' if it is followed by an underscore and a number? I tried a few regular expressions tutorials and I am not quite following them.