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
Asked
Active
Viewed 167 times
-2

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 Answers
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
-
Can i get the pattern for this 1462111462 , i tries with re.match("\d(\d{3})\1(\d)\2{2}(\d{3}\1$',1462111462') , but not working – sriman narayana Sep 17 '19 at 16:10
-
-
-
It's not incremental value. But if you want, you can use pattern = re.compile("\d+"). I don't think I'm exactly understanding what you want to say though. – nagataaaas Sep 17 '19 at 16:48
-
sorry this is a sepearte match . i want to find a pattern in the above number 1 462 111 462 like ? ABC XXX ABC – sriman narayana Sep 17 '19 at 16:53
-
re.compile(r"\d?(\d{3})([0-9])\2{2}\1") this worked totally fine for me. – nagataaaas Sep 17 '19 at 18:29
-
-
could be please help for the pattern (ABABAAAXYZ) example is 4343555123 – sriman narayana Sep 20 '19 at 15:55
-
This getting too far from the beginning. Please post another question and I'll answer it. – nagataaaas Sep 21 '19 at 10:50
-