I want to get all substrings between two characters from one long string.
For example, the string can be
This is an example (sentence), and I need to (get) substrings that are (between) parentheses.
and then I need to get all substrings between the parentheses. In the above example, I need to get: sentence, get, and between.
There is no way to know how many parentheses exist in the string.
If MyText is your longer text, you can get each match by assigning a MatchCollection type variable to System.Text.RegularExpressions.Regex.Matches(MyText, "(?<=\().*(?=\))").
i think that dont look very good, wont it get the first ( and the first ) in one big result?
Try this expression: \((.*?)\) and use the first Group to exclude the brackets…