I have a substring of text like so:
Serial Port Name (COM 1)
How would I go about getting the contents of the above parenthesis?
Thank you in advance.
I have a substring of text like so:
Serial Port Name (COM 1)
How would I go about getting the contents of the above parenthesis?
Thank you in advance.
This is what regular expressions are ideal for, although this is a fairly basic match for them:
This expression looks for parentheses - the
\(and\)- with any number of characters in between -.*means match any character except new line zero or more times. The inner part is also wrapped in parentheses to make it a capturing group - ie(.*). This means that the.Groupsproperty can be used to retrieve the individual text from that capturing group. The first group (ie.Groups(0).Value) would be the whole match, and would give you "(COM 1)".