diff --git a/reference/regex/functions/ereg-replace.xml b/reference/regex/functions/ereg-replace.xml index ba50eb8d40..b7be7f864a 100644 --- a/reference/regex/functions/ereg-replace.xml +++ b/reference/regex/functions/ereg-replace.xml @@ -1,13 +1,13 @@ - - + ereg_replace Replace regular expression - - Description + + + &reftitle.description; stringereg_replace stringpattern @@ -19,26 +19,56 @@ pattern, then replaces the matched text with replacement. - - The modified string is returned. (Which may mean that the - original string is returned if there are no matches to be - replaced.) - - - If pattern contains parenthesized - substrings, replacement may contain - substrings of the form - \\digit, which will - be replaced by the text matching the digit'th parenthesized - substring; \\0 will produce the entire - contents of string. Up to nine substrings may be used. - Parentheses may be nested, in which case they are counted by the - opening parenthesis. - - - If no matches are found in string, then - string will be returned unchanged. - + + + + &reftitle.parameters; + + + + pattern + + + A POSIX extended regular expression. + + + + + replacement + + + If pattern contains parenthesized substrings, + replacement may contain substrings of the form + \\digit, which will be + replaced by the text matching the digit'th parenthesized substring; + \\0 will produce the entire contents of string. + Up to nine substrings may be used. Parentheses may be nested, in which + case they are counted by the opening parenthesis. + + + + + string + + + The input string. + + + + + + + + + &reftitle.returnvalues; + + The modified string is returned. If no matches are found in + string, then it will be returned unchanged. + + + + + &reftitle.examples; For example, the following code snippet prints "This was a test" three times: @@ -102,6 +132,10 @@ $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", + + + + &reftitle.notes; preg_replace, which uses a Perl-compatible @@ -109,13 +143,23 @@ $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", ereg_replace. + + + + &reftitle.seealso; - See also ereg, eregi, - eregi_replace, str_replace, and - preg_match. + + ereg + eregi + eregi_replace + str_replace + preg_match + + + - + ereg Regular expression match - - Description + + + &reftitle.description; intereg stringpattern stringstring arrayregs - - - preg_match, which uses a Perl-compatible - regular expression syntax, is often a faster alternative to - ereg. - - Searches a string for matches to the regular expression given in pattern in a case-sensitive way. - - If matches are found for parenthesized substrings of - pattern and the function is called with - the third argument regs, the matches will - be stored in the elements of the array - regs. $regs[1] will contain the substring - which starts at the first left parenthesis; $regs[2] will contain - the substring starting at the second, and so on. $regs[0] will - contain a copy of the complete string matched. - - - - Up to (and including) PHP 4.1.0 $regs will be - filled with exactly ten elements, even though more or fewer than - ten parenthesized substrings may actually have matched. This has - no effect on ereg's ability to match more - substrings. If no matches are found, $regs - will not be altered by ereg. - - - - Returns the length of the matched string if a match for pattern was - found in string, or &false; if no matches - were found or an error occurred. + + + + &reftitle.parameters; + + + + pattern + + + Case sensitive regular expression. + + + + + string + + + The input string. + + + + + regs + + + If matches are found for parenthesized substrings of + pattern and the function is called with the + third argument regs, the matches will be stored + in the elements of the array regs. + + + $regs[1] will contain the substring which starts at the first left + parenthesis; $regs[2] will contain the substring starting at the + second, and so on. $regs[0] will contain a copy of the complete string + matched. + + + + + + + + + &reftitle.returnvalues; + + Returns the length of the matched string if a match for + pattern was found in string, + or &false; if no matches were found or an error occurred. + + If the optional parameter regs was not passed or the length of the matched string is 0, this function returns 1. - - - The following code snippet takes a date in ISO format - (YYYY-MM-DD) and prints it in DD.MM.YYYY format: + + + + &reftitle.examples; <function>ereg</function> example + + The following code snippet takes a date in ISO format (YYYY-MM-DD) and + prints it in DD.MM.YYYY format: + + + + + &reftitle.notes; + + + preg_match, which uses a Perl-compatible + regular expression syntax, is often a faster alternative to + ereg. + + + + + Up to (and including) PHP 4.1.0 $regs will be + filled with exactly ten elements, even though more or fewer than + ten parenthesized substrings may actually have matched. This has + no effect on ereg's ability to match more + substrings. If no matches are found, $regs + will not be altered by ereg. + + + + + + &reftitle.seealso; - See also eregi, ereg_replace, - eregi_replace, preg_match, - strpos, and strstr. + + eregi + ereg_replace + eregi_replace + preg_match + strpos + strstr + + + - + eregi_replace Replace regular expression case insensitive - - Description + + + &reftitle.description; stringeregi_replace stringpattern @@ -19,6 +19,56 @@ except that this ignores case distinction when matching alphabetic characters. + + + + &reftitle.parameters; + + + + pattern + + + A POSIX extended regular expression. + + + + + replacement + + + If pattern contains parenthesized substrings, + replacement may contain substrings of the form + \\digit, which will be + replaced by the text matching the digit'th parenthesized substring; + \\0 will produce the entire contents of string. + Up to nine substrings may be used. Parentheses may be nested, in which + case they are counted by the opening parenthesis. + + + + + string + + + The input string. + + + + + + + + + &reftitle.returnvalues; + + The modified string is returned. If no matches are found in + string, then it will be returned unchanged. + + + + + &reftitle.examples; Highlight search results @@ -33,11 +83,19 @@ $body = eregi_replace($pattern, $replacement, $body); + + + + &reftitle.seealso; - See also ereg, eregi, - and ereg_replace. + + ereg + eregi + ereg_replace + + - + eregi Case insensitive regular expression match - - Description + + + &reftitle.description; interegi stringpattern @@ -15,10 +15,67 @@ arrayregs - This function is identical to ereg except - that this ignores case distinction when matching alphabetic - characters. + This function is identical to ereg except that it + ignores case distinction when matching alphabetic characters. + + + + &reftitle.parameters; + + + + pattern + + + Case insensitive regular expression. + + + + + string + + + The input string. + + + + + regs + + + If matches are found for parenthesized substrings of + pattern and the function is called with the + third argument regs, the matches will be stored + in the elements of the array regs. + + + $regs[1] will contain the substring which starts at the first left + parenthesis; $regs[2] will contain the substring starting at the + second, and so on. $regs[0] will contain a copy of the complete string + matched. + + + + + + + + + &reftitle.returnvalues; + + Returns the length of the matched string if a match for + pattern was found in string, + or &false; if no matches were found or an error occurred. + + + If the optional parameter regs was not passed or + the length of the matched string is 0, this function returns 1. + + + + + &reftitle.examples; <function>eregi</function> example @@ -34,12 +91,21 @@ if (eregi('z', $string)) { + + + + &reftitle.seealso; - See also ereg, ereg_replace, - eregi_replace, stripos, and - stristr. + + ereg + ereg_replace + eregi_replace + stripos + stristr + + - + split Split string into array by regular expression - - Description + + + &reftitle.description; arraysplit stringpattern stringstring intlimit - - - preg_split, which uses a Perl-compatible regular - expression syntax, is often a faster alternative to - split. If you don't require the power of regular - expressions, it is faster to use explode, which - doesn't incur the overhead of the regular expression engine. - - + + Splits a string into array by regular expression. + + + + + &reftitle.parameters; + + + + pattern + + + Case sensitive regular expression. + + + If you want to split on any of the characters which are considered + special by regular expressions, you'll need to escape them first. If + you think split (or any other regex function, for + that matter) is doing something weird, please read the file + regex.7, included in the + regex/ subdirectory of the PHP distribution. It's + in manpage format, so you'll want to do something along the lines of + man /usr/local/src/regex/regex.7 in order to read it. + + + + + string + + + The input string. + + + + + limit + + + If limit is set, the returned array will + contain a maximum of limit elements with the + last element containing the whole rest of + string. + + + + + + + + + &reftitle.returnvalues; Returns an array of strings, each of which is a substring of - string formed by splitting it on - boundaries formed by the case-sensitive regular expression - pattern. If limit - is set, the returned array will contain a maximum of - limit elements with the last element - containing the whole rest of string. If - an error occurs, split returns &false;. + string formed by splitting it on boundaries formed + by the case-sensitive regular expression pattern. - To split off the first four fields from a line from - /etc/passwd: + If there are n occurrences of + pattern, the returned array will contain + n+1 items. For example, if + there is no occurrence of pattern, an array with + only one element will be returned. Of course, this is also true if + string is empty. If an error occurs, + split returns &false;. + + + + &reftitle.examples; <function>split</function> example + + To split off the first four fields from a line from + /etc/passwd: + - - If there are n occurrences of - pattern, the returned array will contain - n+1 items. For example, if - there is no occurrence of pattern, an array with - only one element will be returned. Of course, this is also true if - string is empty. - - - To parse a date which may be delimited with slashes, dots, or - hyphens: - <function>split</function> example + + To parse a date which may be delimited with slashes, dots, or hyphens: + \n"; - - - For users looking for a way to emulate Perl's @chars = - split('', $str) behaviour, please see the examples for - preg_split or str_split. - - - - Please note that pattern is a regular - expression. If you want to split on any of the characters which - are considered special by regular expressions, you'll need to - escape them first. If you think split (or - any other regex function, for that matter) is doing something - weird, please read the file regex.7, - included in the regex/ subdirectory of the - PHP distribution. It's in manpage format, so you'll want to do - something along the lines of man - /usr/local/src/regex/regex.7 in order to read it. - - - - See also: preg_split, spliti, - str_split, - explode, implode, - chunk_split, and wordwrap. - - + + + &reftitle.notes; + + + preg_split, which uses a Perl-compatible regular + expression syntax, is often a faster alternative to + split. If you don't require the power of regular + expressions, it is faster to use explode, which + doesn't incur the overhead of the regular expression engine. + + + + + For users looking for a way to emulate Perl's @chars = + split('', $str) behaviour, please see the examples for + preg_split or str_split. + + + + + + &reftitle.seealso; + + + preg_split + spliti + str_split + explode + implode + chunk_split + wordwrap + + + + + - + spliti Split string into array by regular expression case insensitive - - Description + + + &reftitle.description; arrayspliti stringpattern @@ -15,10 +15,79 @@ intlimit - This function is identical to split except - that this ignores case distinction when matching alphabetic - characters. + Splits a string into array by regular expression. + + This function is identical to split except that this + ignores case distinction when matching alphabetic characters. + + + + + &reftitle.parameters; + + + + pattern + + + Case insensitive regular expression. + + + If you want to split on any of the characters which are considered + special by regular expressions, you'll need to escape them first. If + you think split (or any other regex function, for + that matter) is doing something weird, please read the file + regex.7, included in the + regex/ subdirectory of the PHP distribution. It's + in manpage format, so you'll want to do something along the lines of + man /usr/local/src/regex/regex.7 in order to read it. + + + + + string + + + The input string. + + + + + limit + + + If limit is set, the returned array will + contain a maximum of limit elements with the + last element containing the whole rest of + string. + + + + + + + + + &reftitle.returnvalues; + + Returns an array of strings, each of which is a substring of + string formed by splitting it on boundaries formed + by the case-sensitive regular expression pattern. + + + If there are n occurrences of + pattern, the returned array will contain + n+1 items. For example, if + there is no occurrence of pattern, an array with + only one element will be returned. Of course, this is also true if + string is empty. If an error occurs, + split returns &false;. + + + + + &reftitle.examples; This example splits a string using 'a' as the separator : @@ -47,12 +116,22 @@ Array + + + + &reftitle.seealso; - See also preg_split, split, - explode, and implode. + + preg_split + split + explode + implode + + + - + sql_regcase Make regular expression for case insensitive match - - Description + + + &reftitle.description; stringsql_regcase stringstring + + Creates a regular expression for a case insensitive match. + + + + + &reftitle.parameters; + + + + string + + + The input string. + + + + + + + + + &reftitle.returnvalues; Returns a valid regular expression which will match string, ignoring case. This expression is - string with each alphabetic character converted to a - bracket expression; this bracket expression contains that - character's uppercase and lowercase form. Other characters remain unchanged. + string with each alphabetic character converted to + a bracket expression; this bracket expression contains that character's + uppercase and lowercase form. Other characters remain unchanged. + + + + &reftitle.examples; <function>sql_regcase</function> example @@ -42,7 +69,9 @@ echo sql_regcase("Foo - bar."); products which support only case sensitive regular expressions. + +