Posts

Showing posts from February 14, 2019

Using regex to match numbers which have 5 increasing consecutive digits somewhere in them

Image
Clash Royale CLAN TAG #URR8PPP 16 3 First off, this has sort of been asked before. However I haven't been able to modify this to fit my requirement. In short: I want a regex that matches an expression if and only if it only contains digits, and there are 5 (or more) increasing consecutive digits somewhere in the expression. I understand the logic of ^(?=d5$)1*2*3*4*5*6*7*8*9*0*$ however, this limits the expression to 5 digits. I want there to be able to be digits before and after the expression. So 1111345671111 should match, while 11111 shouldn't. I thought this might work: ^[0-9]*(?=d50*1*2*3*4*5*6*7*8*9*)[0-9]*$ which I interpret as: ^$ : The entire expression must only contain what's between these 2 symbols [0-9]* : Any digits between 0 - 9 , 0 or more times followed by: (?=d50*1*2*3*4*5*6*7*8*9*) : A part where at least 5 increasing digits are found followed by: [0-9]* : Any digits between 0 - 9 , 0 or more times. However this regex is incorrect, as fo...