Here is my regex ^((\{.+:.+\})|([^{:}]))+?$
.
Here is what i want:
Valid case: {test:test1} {test2:test3} test4 test5
.
Invalid case: {test:}
, {test1: test2
, test1: test3}
.
It's mean whenever my string have one of this three character: '{' ':', '}'
it must also have 2 remaning character.
My regex is working well when my string not end with }
character. I guess it's because of greedy quantifier. But i already put ?
character after +
quantifier it's still not working. What am I doing wrong?