I have a path and I want to get the part of a path before my match:
knowing
I tried with RegEx but I don't know how to be elegant.. I'm only able to find MYWORD position and then use the substring.
Is there a smarter solution?
string s1= @"c:\temp\lev1\lev2\lev3\MYWORD\lev5\lev6";
string mtch ="MYWORD"
knowing
s1
and mtch
I want to get the part of path before mtch, so @"c:\temp\lev1\lev2\lev3\".I tried with RegEx but I don't know how to be elegant.. I'm only able to find MYWORD position and then use the substring.
Is there a smarter solution?