Using Regular Expression to pull out a Server Name

  • Thread starter Thread starter Andrew
  • Start date Start date
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
 
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}
 
Back
Top