I am getting below string as output
RX Power: -3.4 dBm (460.9uW)
I tried below code but I am getting output like
: -3.4 d
I want output
-3.4
$pattern = '(?s)\:.*? d+'
[regex]::Matches($RXTX_Data[0], $pattern).Value
Please let me know what is missing here
>Solution :
Try \s(-?\d+.?\d+)\s for your pattern.
- \s for whitespace character on either side of number
- -? for checking if ‘-‘ is in number group
- .? for checking if ‘.’ is in number group
- \d+ for matching 1 or more numbers in number group
- () for specifying the group you wish to capture i.e. the number group
It worked for me on https://regex101.com. If you haven’t heard of it, it’s a good place to practice regex.