C# string to VB conversion.

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
 
L

Lucas Tam

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?
 
G

Guest

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?
 
L

Lucas Tam

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top