How to remove a defined part of a string?

前端 未结 8 1871
死守一世寂寞
死守一世寂寞 2021-01-07 18:19

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?

8条回答
  •  生来不讨喜
    2021-01-07 18:54

    you can use this codes:

    str = str.Substring (10); // to remove the first 10 characters.
    str = str.Remove (0, 10); // to remove the first 10 characters
    str = str.Replace ("NT-DOM-NV\\", ""); // to replace the specific text with blank
    
    //  to delete anything before \
    
    int i = str.IndexOf('\\');
    if (i >= 0) str = str.SubString(i+1);
    

提交回复
热议问题