I am trying to understand the difference between regular expressions that are used in JavaScript and .NET. I have read couple of articles on it,
Differences between C# and JavaScript Regular Expressions? https://www.codeproject.com/Questions/626385/Regex-pattern-for-csharp-and-js
What i understood from both of these questions is that .NET have support for some extended characters and JavaScript have some limitations.
Is it safe to say that if a regular expression works in JavaScript then it will definitely work in .NET?
Desired result: I want to maintain a list of common regular expressions that work on both JavaScript and .NET.
The .NET framework includes the flag RegexOptions.ECMAScript.
ECMAScript was created to standardise JavaScript, so you will find that different JavaScript engines will have differing levels of support for the ECMAScript standard and its revisions.
The documentation contains some specific notes on the differences in ECMAScript Matching Behaviour which would be worth noting.
So in short; using the RegexOptions.ECMAScript flag in C# and developing your regular expressions - you should then find that your regular expressions then work in JavaScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With