Is there a syntax difference in writing regular expressions in C# and Java?
How can I have the equivalence of the following code in c#
Pattern.matcher(word).matches();
where in pattern I have "\\.|[!?]+"
There is no Pattern Class in C#.
I am using Rejex instead of Pattern that is a replica in C#. but I am unable to get a replica of methods matcher() matches() in Regex.
Given almost every regular expression implementation has differences I would expect that .NET and Java regular expressions are different. You can check out their documentation (for .NET it is here).
A better source would be Friedl’s Mastering Regular Expressions which covers the details of how different regex engines (including Java and .NET differ).
To match a regular expression in .NET use the
Regexclass. Eg.:where the instance of
Matchincludes all the details of the single (as above) or multiple (using methodMatches) matches and any captures. Or with its propertySuccessfalse of course.If by
rejexyou mean Rejex the JavaScript regular expression editor then that’ll be using the JavaSript regular expression engine; which is different again.