This is a line in a log file:
$line = 'to devices Headset Earphone (Some Device)'
I need the result done with an one liner regex only (if possible):
$result = 'Some Device'
I have it working in two lines:
$InsideLoopLine = [regex]::Matches($Line, '^.*to devices Headset.*$')
[regex]::Matches($InsideLoopLine,'(?<=\().*(?=\))')
New info 1 : @WiktorStribiżew
Code:
$Line = 'to devices Headset Earphone (Some Device)'
([regex]::Matches($Line,'\bto devices Headset.*?\(([^()]+)')).Value
Result:
to devices Headset Earphone (Some Device
New info 2
Code:
$Line = 'to devices Headset Earphone (Some Device)'
([regex]::Matches($Line,'\bto devices Headset.*?\(([^()]+)')).Groups[1].Value
Result:
Some Device