I have a regex that I want to deny, for example.
/(.{0,4})
which String.matches returns next
"/1234" true "/12" true "/" true "" false "1234" false "/12345" false
Is there a way to deny (using only regx only) so that they are as follows:
"/1234" false "/12" false "/" false "" true "1234" true "/12345" true
I am looking for a general solution that will work for any regx without re-writing the entire regex.
I reviewed the following How to undo all regex? using (?! pattern), but that doesn't seem to work for me.
Next regx
(?!/(.{0,4}))
returns the following:
"/1234" false "/12" false "/" false "" true "1234" false "/12345" false
what I do not want. Any help would be appreciated.
java regex regex-negation
Wayne Dec 22 '11 at 23:12 2011-12-22 23:12
source share