C# string to VB conversion.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following C# string that I need to use in a regular expression for
VB. Does anyone know how I might convert this?

"\<td(\s+(?<Attribute>(?<key>[A-Za-z0-9]+)\s*=\s*""(?<value>[^""]*)""))+\>(?<Message>[A-Za-z0-9 <>,:?.]*)\</td\>"

Thank you.

Kevin
 
I have the following C# string that I need to use in a regular
expression for VB. Does anyone know how I might convert this?

"\<td(\s+(?<Attribute>(?<key>[A-Za-z0-9]+)\s*=\s*""(?<value>[^""]*)""))
+\>(?<Message>[A-Za-z0-9 <>,:?.]*)\</td\>"

Thank you.


Looks fine... it should work in VB.NET. Maybe replace the spaces with \s?
 
When I use this string in the constructor for a regular expression:

Set oRegExp = New
RegExp("\<td(\s+(?<Attribute>(?<key>[A-Za-z0-9]+)\s*=\s*""(?<value>[^""]*)""))+\>(?<Message>[A-Za-z0-9 <>,:?.]*)\</td\>", RegexOptions.MultiLine)

I get:

VBScript compilation error: Expected end of statement(377,37)

The 37 (character count) seems to refer to the beginning of the string so
that is not helpful. 377 (line number) definitely points to this line. When I
remove the only space (in the Message capture group) in the string I still
get the same error so there is something else that is wrong with the string
as far as VB is concerned.

Thank you for your suggestions.

Kevin

Lucas Tam said:
=?Utf-8?B?S2V2aW4gQnVydG9u?= <[email protected]>
wrote in
I have the following C# string that I need to use in a regular
expression for VB. Does anyone know how I might convert this?

"\<td(\s+(?<Attribute>(?<key>[A-Za-z0-9]+)\s*=\s*""(?<value>[^""]*)""))
+\>(?<Message>[A-Za-z0-9 <>,:?.]*)\</td\>"

Thank you.


Looks fine... it should work in VB.NET. Maybe replace the spaces with \s?
 
When I use this string in the constructor for a regular expression:

Set oRegExp = New
RegExp("\<td(\s+(?<Attribute>(?<key>[A-Za-z0-9]+)\s*=\s*""(?<value> [^""
]*)""))+\>(?<Message>[A-Za-z0-9 <>,:?.]*)\</td\>",
RegexOptions.MultiLine)

I get:

VBScript compilation error: Expected end of statement(377,37)

The 37 (character count) seems to refer to the beginning of the string
so that is not helpful. 377 (line number) definitely points to this
line. When I remove the only space (in the Message capture group) in
the string I still get the same error so there is something else that
is wrong with the string as far as VB is concerned.

I see it now, You need to quardruple up your quotes! """" = " within a
string

Sort of ugly huh?
 
Back
Top