6

I'm working on a multiplatform system. We would like to use regex to test strings in a certain format. The regex would be written once in a db and used by the 3 different platforms. So do you know if there are differences in the manner the regex are written? If yes, is it totally different or only a few things are different?

Here is an example:

[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}

Regards

Asciiom
  • 9,867
  • 7
  • 38
  • 57
jobe
  • 325
  • 2
  • 14
  • 25

2 Answers2

4

Simple regex patterns will be fine across different implementations, however there are defferences for more complex matches. Yet there are limited number of common variations, namely POSIX and Perl regex. So you can have two columns for them in DB, which will be quite enough in most of the cases.

Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96
0

Few Conspicuous Differences between C# and JavaScript Regex.

  1. Lookahead is not supported on IE 6 and IE 7.
  2. List of metacharacters supported by JavaScript is much small.
  3. Named groups also don't work well with JavaScript.

Few helpful links. 1. Are Java and C# regular expressions compatible? - Check the very first answer.

  1. http://www.regular-expressions.info/refflavors.html - Lots of differences are given in here.

  2. Java and .Net Regular Expressions - Java and .NET regular expressions.

  3. This excellently written blog may also be of some help - http://www.codinghorror.com/blog/2004/08/java-vs-net-regex-performance.html

I higly recommend RegexBuddy which understands flavors in the different programming languages and makes it easy to see the difference especially for complex patterns.

Community
  • 1
  • 1
verisimilitude
  • 5,077
  • 3
  • 30
  • 35