all groups > dotnet academic > march 2004 >
You're in the

dotnet academic

group:

Regular exprssion different in VBScript and .NET?


Regular exprssion different in VBScript and .NET? GD
3/31/2004 3:36:10 PM
dotnet academic: As an example, in VbScript ".*\Rad.DAT" is considered a valid regular expression, but in VB7 and C# I'm getting following error message
parsing ".*\Rad.DAT" - Unrecognized escape sequence \R. Parameter name: .*\Rad.DAT
This is happening for any character that do not have an correspondent escape sequence.
".*\Aad.DAT" is okay because "\a" is an escape sequence

Here is a program sequence that uses VBScript library and consider the mentioned regular expression as a correct one
Dim regex As VBScript_RegExp_55.RegEx
regex = New VBScript_RegExp_55.RegEx
regex.Pattern = ".*\Rad.DAT
regex.IgnoreCase = Tru
regex.Global = Tru
Matches = regex.Execute(sToMatch
This sequence returns an error
TestRE = ".*\Rad.DAT
Dim reg As Rege
'reg = New Regex(TestRE, RegexOptions.IgnoreCase
reg = New Regex(TestRE, RegexOptions.CultureInvariant And RegexOptions.IgnoreCase
'reg = New Regex(TestRE
Dim m As System.Text.RegularExpressions.Matc
m = reg.Match(strToMatch
Thanks
G
Re: Regular exprssion different in VBScript and .NET? Peter van der Goes
4/1/2004 9:36:03 AM

[quoted text, click to view]
Shot in the dark: (I'm halfway out the door to work :-)
Is it possible that you need to use two \ in your string literal to indicate
that the "\" is intended to be the backslash character and not part of an
escape sequence?
Will ".*\\Rad.DAT" work?

AddThis Social Bookmark Button