Negative look ahead java
java, regex
Solution
A(?!\d{5,6}B).*B
You only want to do the lookahead once, right after the `A`. And you have to include the `B` in the lookahead so it doesn't reject anything with more than six digits.
Problem
I need an expression to capture a string like this: "A"[A string that is NOT atleast 5 and atmost 6 digits]"B", In other words capture anything that is NOT the following `A[0-9][0-9][0-9][0-9][0-9]B` `A[0-9][0-9][0-9][0-9][0-9][0-9]B` I have tried the negative look ahead `regex = "a((?![0-9]{5,6}).)*d" ;` But it fails to capture all scenarios.