Skip to content

like: $ matches only at the end of the value - #38

Merged
antonfin merged 1 commit into
masterfrom
like-end-of-value
Oct 28, 2026
Merged

antonfin merged 1 commit into
masterfrom
like-end-of-value

Conversation

@koorchik

Copy link
Copy Markdown
Member

LIVR patterns follow JavaScript, where $ matches only at the end of the value. PCRE also matches $ before a trailing newline, so {"like": "^[0-9]{5}$"} accepted "12345\n". The JS reference rejects it.

The like rule now compiles the pattern with the D modifier (PCRE_DOLLAR_ENDONLY), so $ matches only at the very end. The i flag works as before, and so do patterns without anchors.

Testing

  • vendor/bin/phpunit: 77 tests pass on PHP 8.5 (Docker composer:2). The new testLikeMatchesTheEndOfTheValue fails without the fix.
  • vendor/bin/phpcs: no warnings.
  • LIVR 2.0 test suite through the livr-spec.org conformance runner: 68/70. The 2 failures are the known {} vs [] cases (negative/22, negative/27), as before.

This change was prepared with the help of an LLM and tested as described above. Please review it anyway. If it looks good, merge it; a new release isn't required for the conformance site, which tests dev-master.

LIVR patterns follow JavaScript, where $ matches only at the end of the
value. PCRE also matches it before a trailing newline, so
{"like": "^[0-9]{5}$"} accepted "12345\n". The like rule now compiles
the pattern with the D (PCRE_DOLLAR_ENDONLY) modifier.
@antonfin
antonfin merged commit 28079c5 into master Oct 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants