Using Regular Expression to pull out a Server Name

A

Andrew

Hi,

I am trying to use the RegExp object to pull the server name out of a
connection string. The pattern that I am using is "SERVER=.*;" I want to
get the string Server={any server name of any length}; , where the match
stops at the semi-colon. Whenever I do this the I get everything after the
SERVER = part of the connection string . How do I get the match to stop at
the end of the Server section in a connection string?

Thanks
Andrew
 
A

Albert D. Kallal

You can use:

Dim t As String
Dim s As String

t = "Server={any server name of any length};"

s = Split(Split(t, "=")(1), ";")(0)
Debug.Print s

output:

{any server name of any length}
 

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