in reply to
Understanding regex
As you can see in the first example, ":" is part of the matched string, and you're excluding it in the second. That's why it only matchs "d" on:
triple hybrid: dehydrofolate ^--Here
[download]
And substitutes the full "d: d" by only d. Try adding ":" to your character class (
s/([()\w\s:-]+): \1/$1/
).
Comment on
Re: Understanding regex
Select
or
Download
Code
In Section
Seekers of Perl Wisdom