PHP regular expressions /i, /is, /s, / What are isU and so on?
i is not case sensitive
The dot metacharacter (.) in thes pattern matches all characters, including the newline character
Whitespace characters in thex pattern are completely ignored except those that are escaped or within a character class, # outside of an unescaped character class, and all characters between the next newline character, inclusive, Also ignored
A (PCRE_ANCHORED) If this modifier is set, the pattern is forced to be "anchored", that is, it is forced to match only from the beginning of the target string, that is, ^ is automatically added to the beginning of the pattern.
D (PCRE_DOLLAR_ENDONLY) If this modifier is set, dollar metacharacters in the pattern only match the end of the target string. Without this option, if the last character is a newline character, the dollar sign will also match before that character (but not before any other newline character). This option is ignored if the m modifier is set. There is no equivalent modifier in Perl. S When a pattern is going to be used several times, it is worth analyzing it first to speed up matching. If this modifier is set additional analysis will be performed. Currently, analyzing a pattern is only useful for non-anchored patterns that do not have a single fixed starting character.
U (PCRE_UNGREEDY) This modifier inverts the value of the number of matches so that it is not repeated by default, but becomes repeated when followed by a "?" This is not compatible with Perl. This option can also be enabled by setting the (?U) modifier in the mode.
X (PCRE_EXTRA) This modifier enables an extra feature in PCRE that is incompatible with Perl. Any backslash in the pattern followed by a letter with no special meaning results in an error, thus preserving this combination for future expansion. By default, like Perl, a backslash followed by a letter with no special meaning is treated as the letter itself. No other traits are currently controlled by this modifier. That is: greedy mode, maximum matching such as: /a[w]+?e/U matches abceade in abceadeddd instead of abce. If no U correction is added, it matches abce u (PCRE_UTF8) This modifier enables a PCRE Extra functionality that is incompatible with Perl. Pattern strings are treated as UTF-8. This modifier is available since PHP 4.1.0 under Unix and since PHP 4.2.3 under win32.
preg_match("/href=\'([\S\s]*)\'/", $str, $match);echo $match[1]; //This is the match inside the brackets
Add "?" to indicate non-greedy matching...
The parameter "i" indicates to ignore case
The parameter "s" indicates that "." in the regular expression can match newlines