RegExpr Help › Differences
RegExpr for VB & VBA was developed to mimic the behavior of regular expressions in the Perl programming language. Specifically, Perl 4.0.1.6 for MS-DOS, with a few differences, plus a few additional features introduced in Perl 5. Known differences are as follows.
The default setting is that the newline character is a 2-character pair CR+LF (Const NewLine = vbCrLf
). The pair CR+LF is treated as two characters otherwise but as one character in the following expressions:
\n | This matches pair CR+LF |
\s | This matches pair CR+LF (two whitespace characters in one go) |
You can't start or end a range with \n with the default setting Const NewLine = vbNewline
since it's two characters, but a range must start and end with just one character. Use \r for CR or \cJ for LF.
The whitespace characters (\s) in RegExpr are: space, the newline sequence, tab (ASCII 9), return (ASCII 13) and line feed (ASCII 10). This doesn't include any other whitespace characters such as form feed as in Perl.
The same difference also applies to the non-whitespace characters (\S).
The word characters (\w) and non-word characters (\W) have a different definition from that of Perl. This also affects word boundary \b and not word boundary \B.
RegExpr requires octal numbers to start with a leading \0 followed by 1 to 3 digits in range \00..\0377. In addition, \0 is the NULL character.
Perl doesn't use the leading zero. It supports 2 to 3 digit octal numbers in range \00..\377. Perl doesn't accept 4-digit sequences such as \0100..\0377. So, while \0377 is octal 377 in RegExpr, it is \037 followed by 7 in Perl. And while \37 is octal 37 in Perl, it is \3 followed by 7 in RegExpr.
The (?imsx) syntax for setting flags, a feature introduced in Perl 5, is not supported. Flags are set in the function call to RegExpr.
Perl also supports numerous newer regex features not mentioned in this help. RegExpr doesn't support them.
©Aivosto Oy · RegExpr Help