Skip to content

Commit c8072da

Browse files
committed
minor #16424 Moving RexExp search to its own heading (ThomasLandauer)
This PR was merged into the 5.3 branch. Discussion ---------- Moving RexExp search to its own heading See symfony/symfony#45032 (comment) I wanted to create a heading ("Search Using a Regular Expression") for this. Is `~~~~` the lowest level already? If yes, I'd suggest to drop the "Method Reference" heading, and promote all included "Methods to..." headings one level. Commits ------- 4efdd76 Include match examples in the code block 683a671 Moving RexExp search to its own heading
2 parents 44cdb2c + 4efdd76 commit c8072da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

components/string.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,15 @@ Methods to Search and Replace
318318
// checks if the string contents are exactly the same as the given contents
319319
u('foo')->equalsTo('foo'); // true
320320

321-
// checks if the string content match the given regular expression
321+
// checks if the string content match the given regular expression.
322+
// You can pass flags for preg_match() as second argument. If PREG_PATTERN_ORDER
323+
// or PREG_SET_ORDER are passed, preg_match_all() will be used.
322324
u('avatar-73647.png')->match('/avatar-(\d+)\.png/');
323325
// result = ['avatar-73647.png', '73647']
326+
u('avatar-73647.png')->match('/avatar-(\d+)(-\d+)?\.png/', \PREG_UNMATCHED_AS_NULL);
327+
// result = ['avatar-73647.png', '73647', null]
328+
u('206-555-0100 and 800-555-1212')->match('/\d{3}-\d{3}-\d{4}/', \PREG_PATTERN_ORDER);
329+
// result = [['206-555-0100', '800-555-1212']]
324330

325331
// checks if the string contains any of the other given strings
326332
u('aeiou')->containsAny('a'); // true

0 commit comments

Comments
 (0)