Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
shorten file paths in a commandline using regex
using System; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(String[] args) { string pattern = @"(""[^\\]+\\)(?:[^\\""]+\\)*([^""]+"")"; string input = "regedit.exe /e:a \"D:\\data\\backup\\laptop\\CCleaner\\CCleaner.reg\" \"HKEY_CURRENT_USER\\Software\\Piriform\\CCleaner\""; string replacement = "$1...\\$2"; Regex rgx = new Regex(pattern); string result = rgx.Replace(input, replacement); Console.WriteLine("Original String: '{0}'", input); Console.WriteLine("Replacement String: '{0}'", result); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
hay
anyonymous type pass to method in c#
String to Byte[] Conversion
learning1
19.05.2020
1234
sadfghjklö
Enigme
Distinct linq not used
Task List
Please log in to post a comment.