My input string looks like this:
&hello=HI1&op=1h23&hello=&op=&hello=HI3&op=&hello=HI4&op=OP4
If hello has text, I'd like the data to be captured. The op parameter is optional and may or may not have a value. In the string above, I would like the following output (each line will be stored as a separate value in an array):
hello=HI&op=1h23
hello=HI3&op=
hello=HI4&op=OP4
I've got it mostly working but the problem is if op has a value with any letters in the word 'hello', the remaining part of op won't be captured. As you can see in the sample string above, the first op value is 1h23, after the h, the values 23 isn't captured.
https://regex101.com/r/Er0kEo/2
I've tried:
/&hello=[A-z 0-9]+&op=[^&hello]*/gi
This mostly works, except if op has a value that contains any of the letters in the word 'hello'. I've also tried:
/&hello=[A-z 0-9]+&op=.+?(?=&hello)/gi
Only captures first input. Also tried (?!&hello) - slightly better but doesn't capture the last input. Tried with \b and didn't get very far, neither did ^&hello$.
I feel like I'm missing something small but 5 hours in, I'm beat.