Good day stack overflow.
I’m a noob in using regex and here is my problem – I need to check a password if it contains 4 consecutive characters. so far what I have just covered is regarding the digits. Here is my regex:
ascending digits – ^.?(?:0123|1234|2345|3456|4567|5678|6789).$
descending digits – ^.?(?:9876|8765|7654|6543|5432|4321|3210).$
This works only for the digits. I know this is already an overkill in regex so I dont want to do it with the letters. It will be waaay too overkill if I do that.
abcdblah //true because of abcd
helobcde //true because of bcde
dcbablah //true beacause of dcba
heloedcb //true because of edcb
Any help would be highly appreciated. Thanks stackoverflow.
here is an idea that doesn’t use regex:
all characters have an ansi value and usually consecutive. so abcd should have let’s say the following ansi values:64,65,66,67
pseudocode:
also repeat in reverse order (c1.ansival+1==c2.ansival) for descending order