FiberOPtics commented on a Page, Basic $regex example  -  Jan 04, 2006

You should always put your expressions between slashes / /
before you run into this situation:

//echo -a $regex(a,moo)

and wonder why it says there is 1 match...

Also, when you create regexes that capture a pattern, it\'s also a good idea to name your regexes, because everytime a regex captures, it overwrites the old results in $regml.

In cases where you are not planning to reference the captured results later with $regml, it is more efficient to create an uncapturing expression:

(?:L|l) instead of (L|l)

but anyway you should just use the i modifier which will make your expressoin case insensitive:

From: if ($regex($1-,(L|l)(O|o)(L|l)) > 0) {

to

if ($regex($1-,/lol/i)) {

The i modifier tells the regex engine that the specified alpha chars are case insensitive.

I could go on and on and give tips for improvement, but that would end up being a tutorial, something that already exists.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.