Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with \X #38

Open
slevithan opened this issue Dec 24, 2024 · 1 comment
Open

Issues with \X #38

slevithan opened this issue Dec 24, 2024 · 1 comment

Comments

@slevithan
Copy link

The output for \X has some issues:

  • When used with target ES2009 or ES2015, it outputs an empty string with no warning.
  • Output for ES2018 ([\P{M}\P{Lm}](?:(?:[\u035C\u0361]\P{M}\p{M}*)|\u200d|\p{M}|\p{Lm}|\p{Emoji_Modifier})*):
    • Should be matched atomically.
    • Doesn't match some emoji correctly (e.g., 🏳️‍🌈 or 👩🏻‍🏫), which is probably among the more common reasons to use \X.
    • It doesn't match \r\n (a very common grapheme) correctly.
    • The specific pattern used seems a bit arbitrary. I understand that it's meant to be an approximation, but I'm not sure what the details are based on. E.g., the inclusion of only U+035C and U+0361 at the position they're at seems arbitrary (unless there's something I'm missing), and also something like 'A\u035CA' should be counted as two graphemes, not one. Etc.

IMO it would be preferable to simplify or otherwise adjust the approximation to something easily understandable/explainable that only has false negatives (rather than a mixture of false positives and negatives).

@jaynetics
Copy link
Owner

When used with target ES2009 or ES2015, it outputs an empty string with no warning.

warnings are not printed to stderr, they are part of the return value (or raised when using the ::new! constructor).

JsRegex.new(/\X/)
=> 
#<JsRegex:0x000000011bddc9a0
 @options="",
 @source="",
 @target="ES2009",
 @warnings=["Dropped unsupported xgrapheme type '\\X' at index 0"]>

jaynetics added a commit that referenced this issue Dec 25, 2024
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

No branches or pull requests

2 participants