Find Sequence of alphabets in the string
-
I need to find 5 sequence of alphabets has exists in a given string using regular expression. Sequence which should check in any of the form like ABCDE, BCDEF, DEFGH, EFGHI,......,PQRST,...,VWZYZ. Eg. 1) ABCDECODEPROJECT - Match (because "ABCDE" has exists in the string) 2) TESTSTRING - Not Match (because No 5 sequence of alphabets) 3) SAMPLEQRSTUEND - Match (because "QRSTU" has exists in the string) 4) WEBSITELMNOPEND - Match (because "LMNOP" has exists in the string) 5) QUESTIONANSWER - Not Match (because No 5 sequence of alphabets) Can you help me on build regular expression to check all possible combination in alphabets?
-
I need to find 5 sequence of alphabets has exists in a given string using regular expression. Sequence which should check in any of the form like ABCDE, BCDEF, DEFGH, EFGHI,......,PQRST,...,VWZYZ. Eg. 1) ABCDECODEPROJECT - Match (because "ABCDE" has exists in the string) 2) TESTSTRING - Not Match (because No 5 sequence of alphabets) 3) SAMPLEQRSTUEND - Match (because "QRSTU" has exists in the string) 4) WEBSITELMNOPEND - Match (because "LMNOP" has exists in the string) 5) QUESTIONANSWER - Not Match (because No 5 sequence of alphabets) Can you help me on build regular expression to check all possible combination in alphabets?
-
I need to find 5 sequence of alphabets has exists in a given string using regular expression. Sequence which should check in any of the form like ABCDE, BCDEF, DEFGH, EFGHI,......,PQRST,...,VWZYZ. Eg. 1) ABCDECODEPROJECT - Match (because "ABCDE" has exists in the string) 2) TESTSTRING - Not Match (because No 5 sequence of alphabets) 3) SAMPLEQRSTUEND - Match (because "QRSTU" has exists in the string) 4) WEBSITELMNOPEND - Match (because "LMNOP" has exists in the string) 5) QUESTIONANSWER - Not Match (because No 5 sequence of alphabets) Can you help me on build regular expression to check all possible combination in alphabets?
This doesn't look like a suitable case for regular expressions. You'd have to build a regex pattern containing every possible sequence to test for, because regex doesn't have a construct for comparing the difference between two characters within a match. It would probably be easier to implement this using a loop. Check each five-character substring from the input to see if it's contained within a string containing the letters in sequence, remembering to account for case and accents if required.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer