in reply to Negating a regexp
It's negative look ahead assertion time again:
#!/usr/bin/perl -w use strict; while (<DATA>) { s/(.*ing)((?!bob|fred|bill)\w+?)(more)/$1HIT$3/; print $_; } __DATA__ somestringbobmoremore somestringfredmoremore somestringbillmoremore somestringtedmore
Prints:
somestringbobmoremore somestringfredmoremore somestringbillmoremore somestringHITmore
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Negating a regexp
by ikegami (Patriarch) on Jan 31, 2006 at 22:49 UTC | |
by GrandFather (Saint) on Jan 31, 2006 at 23:18 UTC | |
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 BrowserUk (Patriarch) on Feb 01, 2006 at 11:16 UTC | |
by jxh (Acolyte) on Feb 02, 2006 at 11:09 UTC | |
by GrandFather (Saint) on Jan 31, 2006 at 22:54 UTC | |
by ikegami (Patriarch) on Jan 31, 2006 at 22:56 UTC | |
by GrandFather (Saint) on Jan 31, 2006 at 23:00 UTC | |
by ikegami (Patriarch) on Jan 31, 2006 at 23:05 UTC | |
|