-1

I have following log string and I need to get from them only MedSoftware part, which means

  • after .com\
  • before first occurence of \

SERVERNAME2018-03-08 18:40:28 File: "x:_default\app.address.com\MedSoftware.data\BackEnd.Technical.Dictionaries.Service-180308182311\Web.config", Name: "dictionaries_data_product", CS: "###connectionStrings.dictionariesdataproduct.connectionString" info: Format of the initialization string does not conform to specification starting at index 0. 6069

Now my regex looks like this:

((?<=.com\\).*(?=\\))

and catches all after .com but goes to LAST occurence of \

the.salman.a
  • 945
  • 8
  • 29
Qex
  • 317
  • 1
  • 3
  • 9

2 Answers2

-1

You can use ((?<=.com\\)[^\\]*(?=\\))

I basically replaced .* by [^\\]* so that it stops at the first occurence of \.

Demo

Zenoo
  • 12,670
  • 4
  • 45
  • 69
-1
\.com\\([^\\]+)\\.*

Imho you don't need something to capture the first com specifically, because that's what RE's normally do anyhow. And if you capture anything but backslashes, that doesn't need greedy-specifiers either. Only the backslashes which need masking, as well as the literal dot, are a bit tricky.

The capturing group \1 or $1 or whatever it is on powershell, contains MedSoftware now.

Demo

user unknown
  • 35,537
  • 11
  • 75
  • 121