Conversation
…rip it out
Previously it injected a raw NBSP byte (`"\xC2\xA0"`) into the patterns, but
under PCRE2’s extended mode (`/x`) and certain locales (notably on macOS after
a `setlocale()` call), that literal byte gets treated as ignorable "whitespace"
in the pattern and is dropped at compile time. This causes regexes to collapse
into zero-length matches.
By switching to the PCRE escape `\x{00A0}` it ensures the NBSP code point
remains in the pattern text, and the regex reliably matches actual non-breaking
spaces across platforms and locales.
Owner
|
Thank you for the report, I'll have a closer look in the next few days. (I'd prefer a solution without a magic constant if possible.) |
Author
|
Did you already have a look? |
Owner
|
Sorry, I did not. But I'm fixing up the current code base for a 7.0 release (probably tomorrow). |
|
Owner
|
HI @wvell! I've re-read the specs and this is a bug in the pattern (that apparently just works unless a locale is set): The
So the simple solution is to wrap the |
Author
|
Nice find! Thanks for the fix :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



We encountered weird behaviour on our mac development stations where the space-collapse-fix would add a space between every character.
The reason seems to be that the /x modifier strips the U::NO_BREAK_SPACE. This only seems to happen on mac when using setlocale before running this function. On ubuntu with all the versions the same(php/pcre) it works normally.
I have attached a small test script that shows the error on my system.
There are multiple issues touching this issue:
PHP version: 8.4.8
PCRE library: 10.45 2025-02-05