match any character but

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Can I use any reg exp(mainly for mod rewrite) where I can match any  
character but a fixed list?

I need to match a string that does not contain any /'s but I don't want to  
have to use a character search string. (I don't see any need to have to  
hardcode it)

that is,


matches any single charactr

and (.*) matches any string

what I want to do is use something like % that means


which means match any character but /.

Of course it would need to be valid and I know I can't make up semantics for  
the reg ex. My point is is that, is that I don't want to have to use  
[a-z0-9\-%&^$#@!etc...] to mean . but not /.

Surely there is a way to exclude a few characters from . without having to  
increase the complexity of the expression 1000 fold?

If you don't get that, then a simple example would be that I have an  
arbitrary string and I want to match only if that string does not contain an  
a. Sure I can so something like  
but surely reg exp has an easier way??? (again, this is specifically for mod  


Re: match any character but

.oO(Jon Slaughter)

Quoted text here. Click to load it

Use a character class with a leading ^ to negate it:


Matches anything that is not a slash.


Re: match any character but

Quoted text here. Click to load it

Ok. Duh. wasn't putting 2 and 2 together.  [^/] should match anything but a  
slash.  lol.


Site Timeline