I have a string that I parse in regex:
"one [two] three [four] five"
I have regex that extracts the bracketed text into <bracket>
, but now I want to add the other stuff (one, three, five) into <text>
, but I want there to be seperate matches.
So either it is a match for <text>
or a match for <bracket>
. Is this possible using regex?
So the list of matches would look like:
text=one, bracketed=null
text=null, bracketed=[two]
text=three, bracketed=null
text=one, bracketed=[four]
text=five, bracketed=null