Issue #306 - The multibyte string library: Testing and corrections, a formal standalone test has been added. Two encodings are added for support. Improved logic to deal with encoding aliases. It seems that installed mbstring extension is not a mandatory requirement anymore. The php-extensions mbstring and iconv are optional: for speed or for supporting some exotic encodings.
* Performs a regular expression match, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param array &$matches (optional) If matches is provided, then it is filled with the results of search (as an array).
* $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.
* @param int $flags (optional) Could be 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 index 0 and its string offset into subject at index 1.
* @param int $offset (optional) 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.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return int|boolean Returns the number of times pattern matches or FALSE if an error occurred.
* Performs a global regular expression match, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags.
* @param int $flags (optional) 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_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;
* 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.
* If no order flag is given, PREG_PATTERN_ORDER is assumed.
* @param int $offset (optional) 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.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return int|boolean Returns the number of full pattern matches (which might be zero), or FALSE if an error occurred.
* Performs a regular expression search and replace, UTF-8 aware when it is applicable.
* @param string|array $pattern The pattern to search for. It can be either a string or an array with strings.
* @param string|array $replacement The string or an array with strings to replace.
* @param string|array $subject The string or an array with strings to search and replace.
* @param int $limit The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
* @param int &$count If specified, this variable will be filled with the number of replacements done.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return array|string|null returns an array if the subject parameter is an array, or a string otherwise.
* If matches are found, the new subject will be returned, otherwise subject will be returned unchanged or NULL if an error occurred.
* Performs a regular expression search and replace using a callback function, UTF-8 aware when it is applicable.
* @param string|array $pattern The pattern to search for. It can be either a string or an array with strings.
* @param function $callback A callback that will be called and passed an array of matched elements in the $subject string. The callback should return the replacement string.
* @param string|array $subject The string or an array with strings to search and replace.
* @param int $limit (optional) The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
* @param int &$count (optional) If specified, this variable will be filled with the number of replacements done.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return array|string Returns an array if the subject parameter is an array, or a string otherwise.
* Splits a string by a regular expression, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param int $limit (optional) If specified, then only substrings up to $limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or null means "no limit" and, as is standard across PHP.
* @param int $flags (optional) $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;
* PREG_SPLIT_DELIM_CAPTURE - if this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well;
* 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.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return array Returns an array containing substrings of $subject split along boundaries matched by $pattern.
* Performs a regular expression match, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param array &$matches (optional) If matches is provided, then it is filled with the results of search (as an array).
* $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.
* @param int $flags (optional) Could be 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 index 0 and its string offset into subject at index 1.
* @param int $offset (optional) 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.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return int|boolean Returns the number of times pattern matches or FALSE if an error occurred.
* Performs a global regular expression match, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags.
* @param int $flags (optional) 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_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;
* 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.
* If no order flag is given, PREG_PATTERN_ORDER is assumed.
* @param int $offset (optional) 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.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return int|boolean Returns the number of full pattern matches (which might be zero), or FALSE if an error occurred.
* Performs a regular expression search and replace, UTF-8 aware when it is applicable.
* @param string|array $pattern The pattern to search for. It can be either a string or an array with strings.
* @param string|array $replacement The string or an array with strings to replace.
* @param string|array $subject The string or an array with strings to search and replace.
* @param int $limit The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
* @param int &$count If specified, this variable will be filled with the number of replacements done.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return array|string|null returns an array if the subject parameter is an array, or a string otherwise.
* If matches are found, the new subject will be returned, otherwise subject will be returned unchanged or NULL if an error occurred.
* Performs a regular expression search and replace using a callback function, UTF-8 aware when it is applicable.
* @param string|array $pattern The pattern to search for. It can be either a string or an array with strings.
* @param function $callback A callback that will be called and passed an array of matched elements in the $subject string. The callback should return the replacement string.
* @param string|array $subject The string or an array with strings to search and replace.
* @param int $limit (optional) The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
* @param int &$count (optional) If specified, this variable will be filled with the number of replacements done.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return array|string Returns an array if the subject parameter is an array, or a string otherwise.
* Splits a string by a regular expression, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string.
* @param int $limit (optional) If specified, then only substrings up to $limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or null means "no limit" and, as is standard across PHP.
* @param int $flags (optional) $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;
* PREG_SPLIT_DELIM_CAPTURE - if this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well;
* 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.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return array Returns an array containing substrings of $subject split along boundaries matched by $pattern.