I have string which contains all digits.
I want to check whether:
- all the digits are in the range of
0-4, and - the minimum length of the string should be
5
So, I used this regex:
(?=^\d{5,}$)(^[0-4]*$) //works
As expected this does the job
But the above regex when used with positive look behind doesn’t work
(?<=^\d{5,}$)(^[0-4]*$) //doesn't work
Why does positive look behind doesn’t work but look ahead work’s in this case
EDIT
Yes,I can use
^[0-4]{5,}$
But the question is why look-behind didnt work in the above case
This was in reference to THIS question where lookahead worked but not lookbehind
Shouldn’t you look from behind, to match a “look behind assertion” ?
i.e.
As it stands now, you want this:
[0-4]Which basically reduces to
false