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

Regex seems to yield different results with Fable #2322

Closed
lfr opened this issue Dec 17, 2020 · 5 comments
Closed

Regex seems to yield different results with Fable #2322

lfr opened this issue Dec 17, 2020 · 5 comments

Comments

@lfr
Copy link

lfr commented Dec 17, 2020

Repro code

Regex.IsMatch("\\p{C}", "a\nb") // false (FABLE)
Regex.IsMatch("\\p{C}", "a\nb") // true (non-FABLE)

Related information

  • Fable version: 2.13.0
  • Windows
@lfr
Copy link
Author

lfr commented Dec 17, 2020

From F# fiddle:
image

@alfonsogarciacaro
Copy link
Member

How are you evaluating the F# fiddle? If I try this in F# interactive I get false too.

image

@lfr
Copy link
Author

lfr commented Dec 18, 2020

Ok, it must be a bug with .NET 5 then, I evaluated it with dotnetfiddle.net that's probably still running on an earlier version.

@lfr lfr closed this as completed Dec 18, 2020
@inosik
Copy link
Contributor

inosik commented Dec 18, 2020

.NET 5 behaves differently on Windows in regards to the previous versions, see dotnet/runtime#43736. This probably affects Regex as well.

Also, note that Fable translates to JavaScript and isn't a fully fledged .NET runtime for the browser. So this is actually a mismatch between .NET and the browser.

@alfonsogarciacaro
Copy link
Member

Thanks @inosik ! Yes, sorry. Forgot to say that, as mention in the docs, regex in Fable behave as if you're using the RegexOptions.ECMAScript flag (no named groups for example) so it's better to use it explicitly for a proper comparison.

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

3 participants