Are C# and JavaScript Regular Expressions different?
Is there a list of these differences?
Conclusion. In a nutshell, the main difference between C and C++ is that C is a procedural with no support for objects and classes whereas C++ is a combination of procedural and object-oriented programming languages.
Compared to C++, C is the simpler and ultimately faster programming language. C is procedural and does not support classes and objects, meaning it has less functionality than C++. This allows you to spend more time focusing on what you can do with C's libraries, especially at the OS level.
Let's continue with a discussion of all the five different standards of C — K&R C, ANSI C, C99, C11 and Embedded C. For the purposes of our discussion, the compiler used is the gcc C compiler from the GNU Compiler Collection (GCC).
There is a major difference between C and C++. The C language is a procedural one that provides no support for objects and classes. On the other hand, the C++ language is a combination of object-oriented and procedural programming languages.
Here's a difference we bumped into that I haven't seen documented anywhere, so I'll publish it, and the solution, here in the hope that it will help someone.
We were testing "some but not all" character classes, such as "A to Z but not Q, V or X", using "[A-Z-[QVX]]" syntax. Don't know where we found it, don't know if it's documented, but it works in .Net.
For example, in Powershell, using the .Net regex class,
[regex]::ismatch("K", "^[A-Z-[QVX]]$")
returns true. Test the same input and pattern in JavaScript and it returns false, but test "K" against "^[A-Z]$" in JavaScript and it returns true.
You can use the more orthodox approach of negative lookahead to express "A to Z but not Q, V or X", eg "^(?![QVX])[A-Z]$", which will work in both Powershell and (modern) JavaScript.
Given Ben Atkin's point above about IE6 and IE7 not supporting lookahead, it may be that the only way to do this in a fool-proof (or IE7-proof) way is to expand the expression out, eg "[A-Z-[QVX]" -> "ABCDEFGHIJKLMNOPRSTUWYZ". Ouch.
First, some resources:
Here are a few differences:
x(?=y)
in the MDC guide for for examples.)(?<foo>)
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