in reply to Re^2: Negating a regexp
in thread Negating a regexp
Modified regex to accomodate bil:
#!/usr/bin/perl -w use strict; while (<DATA>) { s/(.*ing)((?!bob|fred|bill(?!ess))\w+?)(more|less)/$1HIT$3/; print $_; } __DATA__ somestringbobmoremore somestringfredmoremore somestringbillmoremore somestringtedmore somestringbilless
Prints:
somestringbobmoremore somestringfredmoremore somestringbillmoremore somestringHITmore somestringHITless
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Negating a regexp
by jxh (Acolyte) on Feb 01, 2006 at 10:23 UTC | |
by GrandFather (Saint) on Feb 01, 2006 at 10:34 UTC | |
by jxh (Acolyte) on Feb 01, 2006 at 10:42 UTC | |
by GrandFather (Saint) on Feb 01, 2006 at 10:57 UTC | |
by jxh (Acolyte) on Feb 01, 2006 at 11:04 UTC | |
by BrowserUk (Patriarch) on Feb 01, 2006 at 11:16 UTC | |
by jxh (Acolyte) on Feb 02, 2006 at 11:09 UTC |