in reply to Understanding regex
The character class in your second example doesn't include ':' among the permitted characters, and this stops it being able to match the original duplicated substring. As a result it walks through the string looking for a duplicate that it can match, and 'd: d' is the first one it finds.
To match the initial duplicate with the character class, add the colon to the character class:
s/([:()\w\s-]+): \1/$1/;
Hugo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Understanding regex
by Hena (Friar) on Apr 29, 2005 at 11:44 UTC | |
by Fletch (Bishop) on Apr 29, 2005 at 12:57 UTC | |
by eXile (Priest) on Apr 29, 2005 at 13:12 UTC |