in reply to RegExp to exclude 2-byte characters
Negating multiple-byte regular expressions is quite a pain. It is possible but even truely great regex hackers get it wrong over and over (I've seen it). An informative example is the classic failures at getting a regular expression to match C-style /* comments */ (without using .*? which is flawed if used as part of a larger regular expression).
So don't negate the regular expression, reverse the process. That is, rather than deleting things that match, keep things that match: $string= join "", $string =~ /((?:$re)+)/g; where $re is your current regex minus the parens and with the typo fixed (a dropped ]).
- tye (but my friends don't call me not /^[^T][^y][^e]$/)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: RegExp to exclude 2-byte characters
by feloniousMonk (Pilgrim) on Apr 10, 2001 at 22:33 UTC |