Originally posted by mrcaveman
I guess "/" is to take away the addslashes().
It's to start the regexp; there's another one at the end.
I do not know what "\s" does.
Any whitespace character; space, tab, newline or similar.
The "." is to match any character beside new line, right?
Right (but see below)
I don't know what "+?" stands for, but I guess it says something like ' until ">" '.
Effectively: + means to match the preceding part of the regexp (in this case the "any character" dot one or more times. Problem is, ">" counts as "any character"; the "?" is therefore attached to the "+" so that it doesn't get carried away and match too much. The usually behaviour for + and * is to "match as much as possible", ? changes that to "mach as much as necessary.
I have no clue what "/is" does.
The end of the regexp, followed by a couple of modifiers: i makes matching case-insensitive, so that "p" will also match "P", and s (I think it's supposed to represent "single line") modifies the behaviour of "." so that \n does count as "any character" - otherwise the regexp would fail to match paragraph tags that wrap across more than one line.
The other one is a bit hairier. The tricky bit is
((?!<\/span>).)*
Okay, so the * means "zero or more of the preceding"; the absence of a following ? means that it will try and match as much as possible. But as much as possible of what?
(?!<\/span>).
The dot we already understand; the the cool bit is what in regular-expression circles is called a "forward negative assertion". We look forward from where we are right now, and only match what follows if we don't see the pattern described in the assertion. In this particular case we match the next character (via the ".") only if it is not the start of a </span> tag.
Chances are, ((?!<\/span>).) could be replaced by .? - but heigho.
The syntax was developed for Perl; Googling for "Perl regular expressions" and variants thereof should net you whole libraries of examples and tutorials. (There are a couple of differences between Perl's regexps and PHP's Perl-compatible regexps, that have to do with Perl-specific things that don't apply to PHP, but those differences are covered in the PHP manual links cited by jernhenrick.)
Regexps are a whole language unto themselves; not as powerful as a full programming language (you can't count in them, for example), but still quite useful.