I have the following which is part of a line in a log file
-FDH-11 TIP: - 146/S Q: 48
which I want to match with regex . Is there a way to get the value of Q in the above input. I am not sure the length between -FDH- and Q: is always the same. So ideally if I found -FDH- and Q: then get the value of Q.
-FDH-.*?\bQ:\s*(\S+)?Q:in the string, the solution below provided by user3354059 should work for you.