From 64a1c7cc9e6c2a82b3dbfe5dcad326021d4cdf8f Mon Sep 17 00:00:00 2001 From: Mehdi Achour Date: Fri, 2 Feb 2007 22:09:12 +0000 Subject: [PATCH] WS, preparing for new doc style git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@228784 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/pcre/functions/preg-grep.xml | 105 +++--- reference/pcre/functions/preg-match-all.xml | 313 +++++++++--------- reference/pcre/functions/preg-match.xml | 259 ++++++++------- reference/pcre/functions/preg-quote.xml | 93 +++--- .../pcre/functions/preg-replace-callback.xml | 11 +- reference/pcre/functions/preg-replace.xml | 3 +- reference/pcre/functions/preg-split.xml | 221 ++++++------- 7 files changed, 498 insertions(+), 507 deletions(-) diff --git a/reference/pcre/functions/preg-grep.xml b/reference/pcre/functions/preg-grep.xml index bc40e2593d..f8b51a0825 100644 --- a/reference/pcre/functions/preg-grep.xml +++ b/reference/pcre/functions/preg-grep.xml @@ -1,56 +1,53 @@ - - - - - preg_grep - - Return array entries that match the pattern - - - - Description - - arraypreg_grep - stringpattern - arrayinput - intflags - + + + + preg_grep + Return array entries that match the pattern + + + Description + + arraypreg_grep + stringpattern + arrayinput + intflags + - - preg_grep returns the array consisting of - the elements of the input array that match - the given pattern. - - - - flags can be the following flag: - - - PREG_GREP_INVERT - - - If this flag is passed, preg_grep returns the - elements of the input array that do not match - the given pattern. - This flag is available since PHP 4.2.0. - - - - - + + preg_grep returns the array consisting of + the elements of the input array that match + the given pattern. + - - Since PHP 4.0.4, the results returned by preg_grep - are indexed using the keys from the input array. If this behavior is - undesirable, use array_values on the array returned by - preg_grep to reindex the values. - + + flags can be the following flag: + + + PREG_GREP_INVERT + + + If this flag is passed, preg_grep returns the + elements of the input array that do not match + the given pattern. + This flag is available since PHP 4.2.0. + + + + + - - - <function>preg_grep</function> example - + + Since PHP 4.0.4, the results returned by preg_grep + are indexed using the keys from the input array. If this behavior is + undesirable, use array_values on the array returned by + preg_grep to reindex the values. + + + + + <function>preg_grep</function> example + ]]> - - - - - + + + + + - - - - preg_match_all - Perform a global regular expression match - - - Description - - intpreg_match_all - stringpattern - stringsubject - arraymatches - intflags - intoffset - - - Searches subject for all matches to the regular - expression given in pattern and puts them in - matches in the order specified by - flags. - - - After the first match is found, the subsequent searches are continued - on from end of the last match. - - - flags can be a combination of the following flags - (note that it doesn't make sense to use - PREG_PATTERN_ORDER together with - PREG_SET_ORDER): - - - PREG_PATTERN_ORDER - - - Orders results so that $matches[0] is an array of full - pattern matches, $matches[1] is an array of strings matched by - the first parenthesized subpattern, and so on. - - - - + + + + preg_match_all + Perform a global regular expression match + + + Description + + intpreg_match_all + stringpattern + stringsubject + arraymatches + intflags + intoffset + + + Searches subject for all matches to the regular + expression given in pattern and puts them in + matches in the order specified by + flags. + + + After the first match is found, the subsequent searches are continued + on from end of the last match. + + + flags can be a combination of the following flags + (note that it doesn't make sense to use + PREG_PATTERN_ORDER together with + PREG_SET_ORDER): + + + PREG_PATTERN_ORDER + + + Orders results so that $matches[0] is an array of full + pattern matches, $matches[1] is an array of strings matched by + the first parenthesized subpattern, and so on. + + + + ]+>(.*)]+>|U", - "example:
this is a test
", +preg_match_all("|<[^>]+>(.*)]+>|U", + "example:
this is a test
", $out, PREG_PATTERN_ORDER); echo $out[0][0] . ", " . $out[0][1] . "\n"; echo $out[1][0] . ", " . $out[1][1] . "\n"; ?> ]]> -
- - This example will produce: - - +
+ + This example will produce: + + example: ,
this is a test
example: , this is a test ]]> -
- - So, $out[0] contains array of strings that matched full pattern, - and $out[1] contains array of strings enclosed by tags. - -
-
-
-
- - PREG_SET_ORDER - + - Orders results so that $matches[0] is an array of first set - of matches, $matches[1] is an array of second set of matches, - and so on. - - + So, $out[0] contains array of strings that matched full pattern, + and $out[1] contains array of strings enclosed by tags. + + +
+ + + + PREG_SET_ORDER + + + Orders results so that $matches[0] is an array of first set + of matches, $matches[1] is an array of second set of matches, + and so on. + + ]+>(.*)]+>|U", - "example:
this is a test
", +preg_match_all("|<[^>]+>(.*)]+>|U", + "example:
this is a test
", $out, PREG_SET_ORDER); echo $out[0][0] . ", " . $out[0][1] . "\n"; echo $out[1][0] . ", " . $out[1][1] . "\n"; ?> ]]> -
- - This example will produce: - - + + + This example will produce: + + example: , example: +example: , example:
this is a test
, this is a test ]]> -
-
-
- - In this case, $matches[0] is the first set of matches, and - $matches[0][0] has text matched by full pattern, $matches[0][1] - has text matched by first subpattern and so on. Similarly, - $matches[1] is the second set of matches, etc. - -
-
- - PREG_OFFSET_CAPTURE - - - If this flag is passed, for every occurring match the appendant string - offset will also be returned. Note that this changes the value of - matches in an array where every element is an - array consisting of the matched string at offset 0 - and its string offset into subject at offset - 1. - This flag is available since PHP 4.3.0 . - - - - - - - If no order flag is given, PREG_PATTERN_ORDER is - assumed. - + + + + + In this case, $matches[0] is the first set of matches, and + $matches[0][0] has text matched by full pattern, $matches[0][1] + has text matched by first subpattern and so on. Similarly, + $matches[1] is the second set of matches, etc. + + + + + PREG_OFFSET_CAPTURE + + + If this flag is passed, for every occurring match the appendant string + offset will also be returned. Note that this changes the value of + matches in an array where every element is an + array consisting of the matched string at offset 0 + and its string offset into subject at offset + 1. + This flag is available since PHP 4.3.0 . + + + + + + + If no order flag is given, PREG_PATTERN_ORDER is + assumed. + - - Normally, the search starts from the beginning of the subject string. The - optional parameter offset can be used to specify - the alternate place from which to start the search. - The offset parameter is available since - PHP 4.3.3. - + + Normally, the search starts from the beginning of the subject string. The + optional parameter offset can be used to specify + the alternate place from which to start the search. + The offset parameter is available since + PHP 4.3.3. + - - - Using offset is not equivalent to - passing substr($subject, $offset) to - preg_match_all in place of the subject string, because - pattern can contain assertions such as - ^, $ or - (?<=x). See preg_match for - examples. - - - - - Returns the number of full pattern matches (which might be zero), - or &false; if an error occurred. - - - - Getting all phone numbers out of some text. - + + + Using offset is not equivalent to + passing substr($subject, $offset) to + preg_match_all in place of the subject string, because + pattern can contain assertions such as + ^, $ or + (?<=x). See preg_match for + examples. + + + + + Returns the number of full pattern matches (which might be zero), + or &false; if an error occurred. + + + + Getting all phone numbers out of some text. + ]]> - - - - - - Find matching HTML tags (greedy) - + + + + + + Find matching HTML tags (greedy) + bold textclick me"; @@ -188,11 +187,11 @@ foreach ($matches as $val) { } ?> ]]> - - - This example will produce: - - + + + This example will produce: + + bold text part 1: @@ -204,16 +203,16 @@ part 1: part 2: click me part 3: ]]> - - - - - See also preg_match, - preg_replace, - and preg_split. - -
-
+ + + + + See also preg_match, + preg_replace, + and preg_split. + + + - - - - preg_match - Perform a regular expression match - - - Description - - intpreg_match - stringpattern - stringsubject - arraymatches - intflags - intoffset - - - Searches subject for a match to the regular - expression given in pattern. - - - If matches is provided, then it is filled with the - results of search. $matches[0] will contain the text - that matched the full pattern, $matches[1] will have - the text that matched the first captured parenthesized subpattern, and so - on. - - - flags can be the following flag: - - - PREG_OFFSET_CAPTURE - - - If this flag is passed, for every occurring match the appendant string - offset will also be returned. Note that this changes the return value - in an array where every element is an array consisting of the matched - string at offset 0 and its string offset into - subject at offset 1. This - flag is available since PHP 4.3.0 . - - - - - The flags parameter is available since - PHP 4.3.0. - + + + + preg_match + Perform a regular expression match + + + Description + + intpreg_match + stringpattern + stringsubject + arraymatches + intflags + intoffset + + + Searches subject for a match to the regular + expression given in pattern. + + + If matches is provided, then it is filled with the + results of search. $matches[0] will contain the text + that matched the full pattern, $matches[1] will have + the text that matched the first captured parenthesized subpattern, and so + on. + + + flags can be the following flag: + + + PREG_OFFSET_CAPTURE + + + If this flag is passed, for every occurring match the appendant string + offset will also be returned. Note that this changes the return value + in an array where every element is an array consisting of the matched + string at offset 0 and its string offset into + subject at offset 1. This + flag is available since PHP 4.3.0 . + + + + + The flags parameter is available since + PHP 4.3.0. + - - Normally, the search starts from the beginning of the subject string. The - optional parameter offset can be used to specify - the alternate place from which to start the search. - The offset parameter is available since - PHP 4.3.3. - - - - Using offset is not equivalent to - passing substr($subject, $offset) to - preg_match in place of the subject string, because - pattern can contain assertions such as - ^, $ or - (?<=x). Compare: - - - + + Normally, the search starts from the beginning of the subject string. The + optional parameter offset can be used to specify + the alternate place from which to start the search. + The offset parameter is available since + PHP 4.3.3. + + + + Using offset is not equivalent to + passing substr($subject, $offset) to + preg_match in place of the subject string, because + pattern can contain assertions such as + ^, $ or + (?<=x). Compare: + + + ]]> - - &example.outputs; - + + &example.outputs; + - - - while this example - - + + + while this example + + ]]> - - - will produce - - + + + will produce + + - - - + + + - - preg_match returns the number of times - pattern matches. That will be either 0 times - (no match) or 1 time because preg_match will stop - searching after the first match. preg_match_all - on the contrary will continue until it reaches the end of - subject. - preg_match returns &false; if an error occurred. - - - - Do not use preg_match if you only want to check if - one string is contained in another string. Use - strpos or strstr instead as - they will be faster. - - - - - Find the string of text "php" - + + preg_match returns the number of times + pattern matches. That will be either 0 times + (no match) or 1 time because preg_match will stop + searching after the first match. preg_match_all + on the contrary will continue until it reaches the end of + subject. + preg_match returns &false; if an error occurred. + + + + Do not use preg_match if you only want to check if + one string is contained in another string. Use + strpos or strstr instead as + they will be faster. + + + + + Find the string of text "php" + ]]> - - - - - - Find the word "web" - + + + + + + Find the word "web" + ]]> - - - - - - Getting the domain name out of a URL - + + + + + + Getting the domain name out of a URL + ]]> - - &example.outputs; - + + &example.outputs; + - - - - - See also preg_match_all, - preg_replace, and - preg_split. - - - + + + + + See also preg_match_all, + preg_replace, and + preg_split. + + + - - - - preg_quote - Quote regular expression characters - - - Description - - stringpreg_quote - stringstr - stringdelimiter - - - preg_quote takes str - and puts a backslash in front of every character that is part of - the regular expression syntax. This is useful if you have a - run-time string that you need to match in some text and the - string may contain special regex characters. - - - If the optional delimiter is specified, it - will also be escaped. This is useful for escaping the delimiter - that is required by the PCRE functions. The / is the most commonly - used delimiter. - - The special regular expression characters are: - . \ + * ? [ ^ ] $ ( ) { } = ! < > | : - - - - <function>preg_quote</function> example - + + + + preg_quote + Quote regular expression characters + + + Description + + stringpreg_quote + stringstr + stringdelimiter + + + preg_quote takes str + and puts a backslash in front of every character that is part of + the regular expression syntax. This is useful if you have a + run-time string that you need to match in some text and the + string may contain special regex characters. + + + If the optional delimiter is specified, it + will also be escaped. This is useful for escaping the delimiter + that is required by the PCRE functions. The / is the most commonly + used delimiter. + + The special regular expression characters are: + . \ + * ? [ ^ ] $ ( ) { } = ! < > | : + + + + <function>preg_quote</function> example + ]]> - - - - - - Italicizing a word within some text - + + + + + + Italicizing a word within some text + ]]> - - - + + + - ¬e.bin-safe; + ¬e.bin-safe; - - + + - + preg_replace_callback @@ -35,7 +34,7 @@ $text = "April fools day is 04/01/2002\n"; $text.= "Last christmas was 12/24/2001\n"; // the callback function -function next_year($matches) +function next_year($matches) { // as usual: $matches[0] is the complete match // $matches[1] the match for the first subpattern @@ -96,11 +95,11 @@ fclose($fp); - - + preg_replace diff --git a/reference/pcre/functions/preg-split.xml b/reference/pcre/functions/preg-split.xml index fc4bd1440b..bf8d42d69b 100644 --- a/reference/pcre/functions/preg-split.xml +++ b/reference/pcre/functions/preg-split.xml @@ -1,84 +1,83 @@ - - - - - preg_split - Split string by a regular expression - - - Description - - arraypreg_split - stringpattern - stringsubject - intlimit - intflags - + + + + preg_split + Split string by a regular expression + + + Description + + arraypreg_split + stringpattern + stringsubject + intlimit + intflags + + + Returns an array containing substrings of + subject split along boundaries matched by + pattern. + + + + If limit is specified, then only substrings up to + limit are returned, and if + limit is -1, it actually means "no limit", which is + useful for specifying the flags. + + + + flags can be any combination of the following flags + (combined with bitwise | operator): + + + PREG_SPLIT_NO_EMPTY + + + If this flag is set, only non-empty pieces will be returned by + preg_split. + + + + + PREG_SPLIT_DELIM_CAPTURE + + + If this flag is set, parenthesized expression in the delimiter pattern + will be captured and returned as well. This flag was added for 4.0.5. + + + + + PREG_SPLIT_OFFSET_CAPTURE + + + If this flag is set, for every occurring match the appendant string + offset will also be returned. Note that this changes the return + value in an array where every element is an array consisting of the + matched string at offset 0 and its string offset + into subject at offset 1. + This flag is available since PHP 4.3.0 . + + + + + + + - Returns an array containing substrings of - subject split along boundaries matched by - pattern. + If you don't need the power of regular expressions, you can choose + faster (albeit simpler) alternatives like explode + or str_split. + - - If limit is specified, then only substrings up to - limit are returned, and if - limit is -1, it actually means "no limit", which is - useful for specifying the flags. - - - - flags can be any combination of the following flags - (combined with bitwise | operator): - - - PREG_SPLIT_NO_EMPTY - - - If this flag is set, only non-empty pieces will be returned by - preg_split. - - - - - PREG_SPLIT_DELIM_CAPTURE - - - If this flag is set, parenthesized expression in the delimiter pattern - will be captured and returned as well. This flag was added for 4.0.5. - - - - - PREG_SPLIT_OFFSET_CAPTURE - - - If this flag is set, for every occurring match the appendant string - offset will also be returned. Note that this changes the return - value in an array where every element is an array consisting of the - matched string at offset 0 and its string offset - into subject at offset 1. - This flag is available since PHP 4.3.0 . - - - - - - - - - If you don't need the power of regular expressions, you can choose - faster (albeit simpler) alternatives like explode - or str_split. - - - - - - <function>preg_split</function> example : Get the parts of a search string - + + + <function>preg_split</function> example : Get the parts of a search string + ]]> - - - - - - Splitting a string into component characters - + + + + + + Splitting a string into component characters + ]]> - - - - - - Splitting a string into matches and their offsets - + + + + + + Splitting a string into matches and their offsets + ]]> - - - will yield: - - + + + will yield: + + - - - - - - Parameter flags was added in PHP 4 Beta 3. - - - - See also spliti, split, - implode, preg_match, - preg_match_all, and - preg_replace. - - - + + + + + + Parameter flags was added in PHP 4 Beta 3. + + + + See also spliti, split, + implode, preg_match, + preg_match_all, and + preg_replace. + + +