diff --git a/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexer.php b/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexer.php index 785cdb634..4a94ece65 100644 --- a/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexer.php +++ b/src/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexer.php @@ -44,8 +44,7 @@ public function __construct(LexerInterface $decoratedLexer) */ public function lex(string $value): array { - $escapedValue = preg_replace('/(\\p{L})@/', '$1\\@', $value); - + $escapedValue = preg_replace('/((\s|^)[^@]?(\p{L}|\p{N}|[+-_.])+?(\p{L}|\p{N}))@/', '$1\\@', $value); return $this->lexer->lex($escapedValue); } } diff --git a/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php b/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php index 38f055037..13d3f32c6 100644 --- a/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php +++ b/tests/FixtureBuilder/ExpressionLanguage/Lexer/ReferenceEscaperLexerTest.php @@ -66,5 +66,7 @@ public function provideValues() yield 'string with a reference with members' => ['bar @foo baz']; yield 'reference in a middle of a word' => ['email@example', 'email\\@example']; + + yield 'email ending with a digit' => ['email1@example', 'email1\\@example']; } }