I have the following string:
\" A B 10\\n\”
In this case, I just want to match the first two letters and the number using a Regex.
I would like to have the matched items on an Array like this:
=> [‘A’, ‘B’, ’10’]
That said, the letters A
, B
and the number 10
are all variables, which means, it could be B
C
22
for example.
The solution that I imagine is something like this:
x = \" A B 10\\n\”.match(regex)
So I can split it to have the desired results.
x[0]
evaluates to A
x[1]
evaluates to B
x[2]
evaluates to 10