Right, [0-9] means match any of the characters 0123456789. The {4} means match any of the preceding characters four times, and {1,2} means match them at least one but not more than two times. The parentheses mean to put whatever is inside them into the variables $regs[1], $regs[2], $regs[3], etc., and I think the entire matching string is put in $regs[0]. The dashes just match dashes. So the first regular expression would match 1998-4-10 (and "1998-4-10" would be put in $regs[0], "1998" in $regs[1], "4" in $regs[2], and "10" in $regs[3]) but not 10-22-1 or a333-aa-9b.
The whole of the second part looks like it goes through looking for plain text URLs and replaces them with HTML links. [[:alpha:]]+:// means match any alphabetic characters at least one time followed by a ://, so for example it would match http:// or ftp://. [^<>[:space:]]+[[:alnum:]/] matches anything except <> or whitespace characters at least one time followed by a / or alphanumeric character at the end of the string. \0 means the entire matched string in the context of that function.
Note there are two types of regular expressions in PHP, Perl-compatible regular expressions with the preg functions, and POSIX extended expressions with the ereg functions. They are similar but there are some minor differences that I don't really know.
Last edited by n0nsensical; 02-04-2004 at 02:11 PM..
|