-2

I am working on Fancy mobile number list using python re. what is the pattern for getting the incremental digits in between the 10 digit mobile number pattern for mobile number xxxxxx1234, xxxxx12345, xxxx123456 etc using python re

sriman narayana
  • 359
  • 2
  • 20
  • use a simple iteration over string and keep track of last value, if the delta between current value last value is one ( -ve or +ve depends how you're subtracting ), than it's a incremental number, and keep track of max length of such to get pattern with most incremental number – Code Maniac Sep 17 '19 at 16:12

1 Answers1

1
import re
pattern = re.compile("0?1?2?3?4?5?6?7?8?9?")
pattern.search("12343445")
<re.Match object; span=(0, 4), match='1234'>

I think this works

nagataaaas
  • 400
  • 2
  • 13