Extract text from a string
The following regex extract anything between the parenthesis:
PS> $prog = [regex]::match($s,'\(([^\)]+)\)').Groups[1].ValuePS> $progSUB RAD MSD 50R IIIExplanation (created with RegexBuddy)Match the character '(' literally «\(»Match the regular expression below and capture its match into backreference number 1 «([^\)]+)» Match any character that is NOT a ) character «[^\)]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»Match the character ')' literally «\)»
Check these links:
If program name is always the first thing in (), and doesn't contain other )s than the one at end, then $yourstring -match "[(][^)]+[)]"
does the matching, result will be in $Matches[0]
Just to add a non-regex solution:
'(' + $myString.Split('()')[1] + ')'
This splits the string at the parentheses and takes the string from the array with the program name in it.
If you don't need the parentheses, just use:
$myString.Split('()')[1]