File tree 2 files changed +34
-0
lines changed
Find-PhoneNumber-in-String 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ def check_phone_number (string ):
2
+ if len (string ) != 12 :
3
+ return False
4
+ for i in range (0 , 3 ):
5
+ if not string [i ].isdecimal ():
6
+ return False
7
+ if string [3 ] != '-' :
8
+ return False
9
+ for i in range (4 , 7 ):
10
+ if not string [i ].isdecimal ():
11
+ return False
12
+ if string [7 ] != '-' :
13
+ return False
14
+ for i in range (8 , 12 ):
15
+ if not string [i ].isdecimal ():
16
+ return False
17
+ return True
18
+
19
+ string = input ("Enter a Sentence: " )
20
+
21
+ for i in range (len (string )):
22
+ split = string [i :i + 12 ]
23
+ if check_phone_number (split ):
24
+ print ('Phone number has been found! : ' + split )
Original file line number Diff line number Diff line change
1
+ # Find Phone Number in a string
2
+
3
+ A python script that will extract phone numbers in a string
4
+
5
+ ## Requirements
6
+ Python 3.7.3
7
+
8
+ ## Usage
9
+ $ python Find-PhoneNumber-in-String.py
10
+ Enter a Sentence: Call me in this number 403-867-2229
You can’t perform that action at this time.
0 commit comments