I have this string: \"NT-DOM-NV\\MTA\" How can I delete the first part: \"NT-DOM-NV\\\" To have this as result: \"MTA\"
How is it possible with RegEx?
You can use this extension method:
public static String RemoveStart(this string s, string text)
{
return s.Substring(s.IndexOf(s) + text.Length, s.Length - text.Length);
}
In your case, you can use it as follows:
string source = "NT-DOM-NV\MTA";
string result = source.RemoveStart("NT-DOM-NV\"); // result = "MTA"
Note: Do not use TrimStart
method as it might trims one or more characters further (see here).
Regex.Replace(@"NT-DOM-NV\MTA", @"(?:[^\\]+\\)?([^\\]+)", "$1")
try it here.