if i have a string of text like below, how can i collect the contents of the brackets in a collection in c# even if it goes over line breaks?
eg…
string s = "test [4df] test [5yu] test [6nf]";
should give me..
collection[0] = 4df
collection[1] = 5yu
collection[2] = 6nf
You can do this with regular expressions, and a bit of Linq.
Output:
Here’s what the regular expression means: