12-13-2008, 12:17 AM
|
#4 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
/(http:\/\/.+?)[\s|\n]/ig creates a regular expression object with the pattern (http:\/\/.+?)[\s|\n] and flags i (case insensitive) and g (global).
The pattern itself searches for (and retains for later) the characters "http://" followed by one or more (+) single characters (.; 'single character' means any character except a newline). The question mark (?) makes the 'one or more single characters' what is called ungreedy (which is important but we can gloss over it right now). Next, [\s|\n] matches either a whitespace character (tab, space, newline), a vertical pipe character or a newline character (I think Wildhoney really meant just \s so that the match stops at whitespace (thanks to the ungreedy repetition earlier)).
Put simply, we match all instances of "http://" followed by one or more characters, followed by a whitespace character.
|
|
|
|