Skip to content

Commit

Permalink
Assert: match() supports escaping % with %%
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Aug 5, 2016
1 parent 7b7ecde commit a28ff10
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Assert

/** used by match(); in values, each $ followed by number is backreference */
public static $patterns = [
'%%' => '%', // one % character
'%a%' => '[^\r\n]+', // one or more of anything except the end of line characters
'%a\?%' => '[^\r\n]*', // zero or more of anything except the end of line characters
'%A%' => '.+', // one or more of anything including the end of line characters
Expand Down
2 changes: 2 additions & 0 deletions tests/Framework/Assert.match.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ $matches = [
["a\nb", "a\t \nb"],
["a\t\r\n\t ", 'a'],
['a', "a\t\r\n\t "],
['%%', '%'],
['%%a%%', '%a%'],
['%a%', 'a b'],
['%a?%', 'a b'],
['%a?%', ''],
Expand Down

0 comments on commit a28ff10

Please sign in to comment.