471,338 Members | 1,509 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Help converting C# Regular Expression to VB.Net??

Hi All.

I'm using some C# code which I translated to vb.net to remove
sourcesafe information from project and solution files. It uses regular
expressions, and the attempt I made at translating the c~ expression
doesn't produce the required results.....

Could some have a look at this and point out where I've gone wrong?

C# Code:
Regex r = new Regex("\\\"Scc\\w*\\\"\\s*=\\s*\\\".*\\\"");

and my stab at VB.Net Code:
Dim objRegEx As New Regex("\\""Scc\w*\\""\s*=\s*\\"".*\\""")

and a second expression:
C# Code:
Regex r = new Regex("Scc\\w*\\s*=\\s*\\\".*\\\"");

and my stab at VB.Net Code:
Dim objRegEx As New Regex("Scc\w*\s*=\s*\\"".*\\""")

Thanks

Alex

Jul 21 '05 #1
2 1874
Its a little tricky not knowing your original intended expression, but
I'll take a stab.

My guess at the VB.NET for the first one would be:
New Regex("\""Scc\w*\""\s*=\s*\"".*\""")

and the second:
New Regex("Scc\w*\s*=\s*\"".*\""")

Note, C# uses \" to represent " while VB.NET uses ""
And C# uses \\ to represent \ while VB.NET does not need to escape a \

If you don't want to escape \ in C#, you can add a @ before the string.
For example:
Regex("\\w*")
can be re-written as
Regex(@"\w*")
Hope that helps.

Joshua Flanagan
http://flimflan.com/blog
al*********@gcc.co.uk wrote:
Hi All.

I'm using some C# code which I translated to vb.net to remove
sourcesafe information from project and solution files. It uses regular
expressions, and the attempt I made at translating the c~ expression
doesn't produce the required results.....

Could some have a look at this and point out where I've gone wrong?

C# Code:
Regex r = new Regex("\\\"Scc\\w*\\\"\\s*=\\s*\\\".*\\\"");

and my stab at VB.Net Code:
Dim objRegEx As New Regex("\\""Scc\w*\\""\s*=\s*\\"".*\\""")

and a second expression:
C# Code:
Regex r = new Regex("Scc\\w*\\s*=\\s*\\\".*\\\"");

and my stab at VB.Net Code:
Dim objRegEx As New Regex("Scc\w*\s*=\s*\\"".*\\""")

Thanks

Alex

Jul 21 '05 #2
Joshua,

Thanks for you help, that did the trick.

Alex

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Steve | last post: by
5 posts views Thread by Bradley Plett | last post: by
4 posts views Thread by Neri | last post: by
1 post views Thread by Rahul | last post: by
3 posts views Thread by Zach | last post: by
4 posts views Thread by vishal | last post: by
8 posts views Thread by Martin Nadoll | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.