Using regex with positive lookbehind in VBA

VBA regex does not support lookbehinds, but in this case, you do not need a positive lookbehind, you just can use a capturing group - "Server: (.*)"` - and then access Group 1 value:

Set regex = CreateObject("vbscript.regexp")
regex.Pattern = "Server: (.*)"
regex.IgnoreCase = True
Set allMatches = regex.Execute("New Linux Server: prod-servername-a001")
If allMatches.Count <> 0 Then
    rng.Value = allMatches(0).Submatches(0)
End If

Here,

  • Server: - matches a string Server: + space
  • (.*) - matches and captures into Group 1 zero or more characters other than a newline up to the end of line.

See more about capturing groups.