diff --git a/components/string.rst b/components/string.rst index f754bfdb7ea..d5110cac96f 100644 --- a/components/string.rst +++ b/components/string.rst @@ -318,9 +318,15 @@ Methods to Search and Replace // checks if the string contents are exactly the same as the given contents u('foo')->equalsTo('foo'); // true - // checks if the string content match the given regular expression + // checks if the string content match the given regular expression. + // You can pass flags for preg_match() as second argument. If PREG_PATTERN_ORDER + // or PREG_SET_ORDER are passed, preg_match_all() will be used. u('avatar-73647.png')->match('/avatar-(\d+)\.png/'); // result = ['avatar-73647.png', '73647'] + u('avatar-73647.png')->match('/avatar-(\d+)(-\d+)?\.png/', \PREG_UNMATCHED_AS_NULL); + // result = ['avatar-73647.png', '73647', null] + u('206-555-0100 and 800-555-1212')->match('/\d{3}-\d{3}-\d{4}/', \PREG_PATTERN_ORDER); + // result = [['206-555-0100', '800-555-1212']] // checks if the string contains any of the other given strings u('aeiou')->containsAny('a'); // true