Are Java and C# regular expressions compatible?

前端 未结 6 2076
醉酒成梦
醉酒成梦 2020-11-29 21:55

Both languages claim to use Perl style regular expressions. If I have one language test a regular expression for validity, will it work in the other? Where do the regular ex

6条回答
  •  悲哀的现实
    2020-11-29 22:25

    Java uses standard Perl type regex as well as POSIX regex. Looking at the C# documentation on regexs, it looks like that Java has all of C# regex syntax, but not the other way around.

    Compare them yourself: Java: C#:

    EDIT: Currently, no other regex flavor supports Microsoft's version of named capture.

提交回复
热议问题