Reputation: 36
I need to validate a regex where between STRING_{here}G_ can be 0 or even 4 digits, I tried the following regex:
(?<=TEST_[0-9]{0,4}G_).*
But the tester returns the error:
Your pattern contains one or more errors, please see the explanation section above.
And when trying to use manually, using two [0-9], it doesn't get my strings
ABC_TEST_20G_a123-abc1
ABC_TEST_100G_abc1
I need a regex that validates both strings and returns what is after G_ Remembering that the regex must have the "TEST_", it is a string that I need to validate
Upvotes: 0
Views: 290
Reputation: 780818
Most regexp engines don't allow lookbehinds to be variable-length, so you can't have a {0,4}
quantifier in it.
Instead of a lookbehind, use a capture group to capture everything after this pattern.
TEST_[0-9]{0,4}G_(.*)
Capture group 1 will contain what you want to get.
Upvotes: 1