Example string
ffff7cp37wicb5.hui.com /images/xyz.jpg HTTP/1.1 HIT 103.195.71.140 image/jpeg "trace-id=3948b327-87d5-a6a0-15e5-3e20ef6d6333;parent-id=540089004159950400;span-id=540089004159950400" ^curl mozilla; haa/7.79.1^ ^max-age=2592000^ 0 NOT_DEFINED
I need to match all spaces except the ones that lie between two carets (^
) so that I can split the above line into tokens
Tried the solution from here using:
arr = str.split(/\s(?![^^]*\^)/g)
Expectation
ffff7cp37wicb5.hui.com
/images/xyz.jpg
HTTP/1.1
HIT
103.195.71.140
image/jpeg
"trace-id=3948b327-87d5-a6a0-15e5-3e20ef6d6333;parent-id=540089004159950400;span-id=540089004159950400"
^curl mozilla; haa/7.79.1^
^max-age=2592000^
0
NOT_DEFINED
Actual
ffff7cp37wicb5.hui.com /images/xyz.jpg HTTP/1.1 HIT 103.195.71.140 image/jpeg "trace-id=3948b327-87d5-a6a0-15e5-3e20ef6d6333;parent-id=540089004159950400;span-id=540089004159950400" ^curl mozilla; haa/7.79.1^ ^max-age=2592000^
0
NOT_DEFINED