I am trying to break text from a text field using some characters as operators. I have a grouping operator (") and an AND operator (+), which is very similar to google. So this text:
box +box +"box" "box" "is.a.box" +"is.a.box" +"is a box"
The following is returned in the text box:
myArray[0] = box myArray[1] = +box myArray[2] = + myArray[3] = "box" myArray[4] = "box" myArray[5] = "is.a.box" myArray[6] = + myArray[7] = "is.a.box" myArray[8] = + myArray[9] = "is a box"
Instead, I want it to return this:
myArray[0] = box myArray[1] = +box myArray[2] = +"box" myArray[3] = "box" myArray[4] = "is.a.box" myArray[5] = +"is.a.box" myArray[6] = +"is a box"
This is the regex that I use:
/[\+\w]+|"[^"]+"/g
How can I divide by and + characters together?
source share