I have a string which is invalid if it has
_ at start ||
_ at end ||
more than one consecutive _ in the middle
but it is valid if more than one non consecutive _
found in a string
examples are
"'test_test_test" - valid
"test_" - invalid
"_test" - invalid
"test_____test" - invalid
I am trying different pattern to match all this condition into one but doesn't seem to work for e.g.("^[__]+") or ("^[_]+") or ("^[_]$+")
If you could help me with regex and some explanation, I would really appreciate!