I am receiving strings from an external client and I am trying to perform regex-ing to extract a certain number and status that are embedded in this string. Here’s the examples of the strings that are coming in.
data = "< REP 1 INPUT_AUDIO_A ON >"
data = "< REP 1 INPUT_AUDIO_A OFF "
data = "< REP 2 INPUT_AUDIO_A ON >"
data = "< REP 2 INPUT_AUDIO_A OFF >"
and so on
I am trying to extract 1, 2 as gate number and the on or off as status in two different variables. I was able to extract numbers with regex as follows.
var gateNumberRegex = /[0-8]/g;
var gateNumber = data.charAt(data.search(gateNumberRegex)); //extract the gate number from string, output is 1 or 2 etc.
Not sure how to extract the on/off status, any pointers?
INPUT_AUDIO_A[\s]+([\w+])\sor\win square brackets,INPUT_AUDIO_A\s+(\w+)is equally fine and more readable.