Permalink
Browse files

Behat generates proper snippets for arguments followed by non-word ch…

…aracter

Closes #448
  • Loading branch information...
1 parent 68e56f0 commit dcdba8cb19d075ba6d4fe81345f17b75369b8072 @everzet everzet committed Feb 11, 2014
@@ -24,9 +24,9 @@ class RegexPatternPolicy implements PatternPolicy
* @var string[string]
*/
private static $replacePatterns = array(
- "/(?<= |^)\\\'(?:((?!\\').)*)\\\'(?= |$)/" => "\\'([^\']*)\\'", // Single quoted strings
- '/(?<= |^)\"(?:[^\"]*)\"(?= |$)/' => "\"([^\"]*)\"", // Double quoted strings
- '/(\d+)/' => "(\\d+)", // Numbers
+ "/(?<=\W|^)\\\'(?:((?!\\').)*)\\\'(?=\W|$)/" => "'([^']*)'", // Single quoted strings
+ '/(?<=\W|^)\"(?:[^\"]*)\"(?=\W|$)/' => "\"([^\"]*)\"", // Double quoted strings
+ '/(?<=\W|^)(\d+)(?=\W|$)/' => "(\\d+)", // Numbers
);
/**
@@ -28,9 +28,9 @@ class TurnipPatternPolicy implements PatternPolicy
* @var string[]
*/
private static $placeholderPatterns = array(
- "/(?<=\s|^)\"[^\"]+\"(?=\s|$)/",
- "/(?<=\s|^)'[^']+'(?=\s|$)/",
- "/(?<=\s|^)\d+/"
+ "/(?<=\W|^)\"[^\"]+\"(?=\W|$)/",
+ "/(?<=\W|^)'[^']+'(?=\W|$)/",
+ "/(?<=\W|^)\d+(?=\W|$)/"
);
/**
@@ -82,7 +82,7 @@ public function transformPatternToRegex($pattern)
self::PLACEHOLDER_REGEXP,
function ($match) {
return sprintf(
- "[\"']?(?P<%s>(?<=\")[^\"]+(?=\")|(?<=')[^']+(?=')|(?<=\s)\w+(?=\s|$))['\"]?",
+ "[\"']?(?P<%s>(?<=\")[^\"]+(?=\")|(?<=')[^']+(?=')|(?<=\W)\w+(?=\W|$))['\"]?",
$match[1]
);
},

0 comments on commit dcdba8c

Please sign in to comment.