Skip to content

Commit

Permalink
minor symfony#16424 Moving RexExp search to its own heading (ThomasLa…
Browse files Browse the repository at this point in the history
…ndauer)

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
  • Loading branch information
wouterj committed Jan 25, 2022
2 parents 44cdb2c + 4efdd76 commit c8072da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c8072da

Please sign in to comment.