regexp to negate 2 chars at once 
Author Message
 regexp to negate 2 chars at once

How can one make a "double sized [^]"?
$ echo bp|perl -ple 's/[^b][^z]//' #wanted to leave only bz
bp
But I want it to fire upon everything except bz.
Kindly only work with the stuff in the s/// string in your answer.
Other workarounds just workaround the question.
Oh, I get it. I'm supposed to write
echo bp|perl -ple 's/[^b]z|b[^z]|[^b][^z]//'
OK, but in fact I'm working with multibyte chars, but I don't want to
"use locale".  And, I also don't want to chop them apart in the
program.  Anyways, let's just say I want to match on everything except
"barney".  Well, I can't do [^barney]. So how does one enjoy [^] for
longer than one char at a time?
--
http://www.*-*-*.com/ (04)25854780
Email broken


Fri, 18 Nov 2005 06:45:39 GMT  
 regexp to negate 2 chars at once

Quote:

> How can one make a "double sized [^]"?
> $ echo bp|perl -ple 's/[^b][^z]//' #wanted to leave only bz
> bp
> But I want it to fire upon everything except bz.
> Kindly only work with the stuff in the s/// string in your answer.
> Other workarounds just workaround the question.
> Oh, I get it. I'm supposed to write
> echo bp|perl -ple 's/[^b]z|b[^z]|[^b][^z]//'
> OK, but in fact I'm working with multibyte chars, but I don't want to
> "use locale".  And, I also don't want to chop them apart in the
> program.  Anyways, let's just say I want to match on everything except
> "barney".  Well, I can't do [^barney]. So how does one enjoy [^] for
> longer than one char at a time?

Look for the (?! ) operator in

   perldoc perlre

--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



Fri, 18 Nov 2005 08:46:22 GMT  
 regexp to negate 2 chars at once

Quote:
> Look for the (?! ) operator in perldoc perlre

I did. Now what?
--
http://jidanni.org/ Taiwan(04)25854780


Fri, 18 Nov 2005 23:15:26 GMT  
 regexp to negate 2 chars at once
Dan Jacobson wrote at Tue, 03 Jun 2003 06:15:26 +0800:

Quote:
>> Look for the (?! ) operator in perldoc perlre

> I did. Now what?

Now, you can try something like
s/(?!bw)..//;

Greetings,
Janek



Sat, 19 Nov 2005 05:06:19 GMT  
 regexp to negate 2 chars at once

Quote:

>> Look for the (?! ) operator in perldoc perlre
> I did. Now what?

Q: I have to put a nail into a wall.
A: Look for a hammer in the garage.
Q: I did. Now what?

SCNR =)

--
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -



Sat, 19 Nov 2005 15:05:13 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. negating a string in a regexp

2. negating qr// regexp

3. negated compiled regexp

4. RegExp Char Class

5. HELP: deactivating regexp-active chars from string?

6. regexp for strings of chars

7. regexp: matching at least n chars out of a string of length m

8. Regexp char class: mixing ranges and negation?

9. Regexp containing plus-chars won't work?!?!?

10. How handle special chars during regexp

11. @chars the same as ($#chars) ?

12. Replacing special chars with special chars

 

 
Powered by phpBB® Forum Software