Log in

View Full Version : Regular expressions


filburt1
04-10-2003, 05:07 PM
Learn them. They look scary but once you get used to them they're a godsend.

This one makes sure a string begins with "message" and is followed by a number:

/^message[0-9]*$/

Looks complex but it means "if the string has nothing but beginning with "message" and then followed by any number of digits and that's it".

This is helpful: http://www.english.uga.edu/humcomp/perl/regex2a.html

:)

Dean C
04-10-2003, 05:41 PM
Hey that might be useful for vbt where when it first opened all releases had to preced with [Release] - ;)

- miSt

filburt1
04-10-2003, 05:47 PM
You mean:

/^\[release\]\w.*/

:p

Zzed
04-10-2003, 07:50 PM
preg_replace() is even more fun. ;) It has the power to match and extract substrings from your match string that can be used within the replace string. :D