[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] Regular expressions (was: Redirecting to a index page depending on group membership on Apache 1.3)



And Lo! The Great Prophet "Rob Keeling" uttered these words of wisdom:
> 
> Ah, right, I see what you mean, so following the same logic ^[a-z]*$ would
> match
> purely alpha usernames? Are these case sensitive? If so I assume there is
> some sort of OR operator.
> 

Yes and yes, if you want case insensitive, then: [A-Za-z]* would do the
job. '[' and ']' mark sets, thus you could have [AGhwNr4]* which would
match anything with any of those characters. You can also have inverse
sets: [^a-z] which matches anything /EXCEPT/ 'a' thru' 'z'.

> 
> Neat things these regular expressions.....
> 

Bloody powerful as well; extended RE's then give you more possibilities,
for example '|' becomes an operator to "or" expressions together, viz:
bob|^[A-Z]*|^0[567]*g.*$ will match anything which matches any of the
three expressions there...so if a line contains bob, starts with capital
letters, or starts with 0 followed by a number of any of 5,6 and 7 up to
a g, then any character to the end of line, then this RE will catch it :)

Chris...



___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.