c# - How to get all string format parameters -
is there way format parameters of string?
i have string: "{0} test {0} test2 {1} test3 {2:####}" result should list: {0} {0} {1} {2:####}
is there built in functionality in .net supports this?
i didn't hear such build-in functionality try (i'm assuming string contains standard format parameters start number digit):
list<string> result = new list<string>(); string input = "{0} test {0} test2 {1} test3 {2:####}"; matchcollection matches = regex.matches(input, @"\{\d+[^\{\}]*\}"); foreach (match match in matches) { result.add(match.value); }
it returns {0} {0} {1} {2:####}
values in list. tehmick's string result empty set.
Comments
Post a Comment