I've tried multiple regex attempts but couldn't find a regular expression that matches phone numbers like below. Can you help me. Thank you.Regex ?
0532-172-17-43
0532-172-1743
0532 172 1743
0532 172 17 43
0532 1721743
05321721743
0 (532) 172 1743
0(532) 172 1743
0 532 172 1743
0 532 172 17 43
0 532 1721743
532-172-1743
532 172 1743
532 172 17 43
532 1721743
2168921222
03124328898
5321721743
(0532)172 17 43
(0532) 172 17 43
(532)172 17 43
(532) 172 17 43
(0532)1721743
(0532) 1721743
(532)1721743
(532) 1721743
(532) 172 1743
(0532) 172 1743
0 312 213 2965
CodePudding user response:
You can use this :
[0-9() -]{10,16}
# Check in Python :
# https://regex101.com/r/LpbhZw/1
<re.Match object; span=(1, 15), match='0532-172-17-43'>
<re.Match object; span=(16, 29), match='0532-172-1743'>
<re.Match object; span=(30, 43), match='0532 172 1743'>
<re.Match object; span=(44, 58), match='0532 172 17 43'>
<re.Match object; span=(59, 71), match='0532 1721743'>
<re.Match object; span=(72, 83), match='05321721743'>
<re.Match object; span=(84, 100), match='0 (532) 172 1743'>
<re.Match object; span=(101, 116), match='0(532) 172 1743'>
<re.Match object; span=(117, 131), match='0 532 172 1743'>
<re.Match object; span=(132, 147), match='0 532 172 17 43'>
<re.Match object; span=(148, 161), match='0 532 1721743'>
<re.Match object; span=(162, 174), match='532-172-1743'>
<re.Match object; span=(175, 187), match='532 172 1743'>
<re.Match object; span=(188, 201), match='532 172 17 43'>
<re.Match object; span=(202, 213), match='532 1721743'>
<re.Match object; span=(214, 224), match='2168921222'>
<re.Match object; span=(225, 236), match='03124328898'>
<re.Match object; span=(237, 247), match='5321721743'>
<re.Match object; span=(248, 263), match='(0532)172 17 43'>
<re.Match object; span=(264, 280), match='(0532) 172 17 43'>
<re.Match object; span=(281, 295), match='(532)172 17 43'>
<re.Match object; span=(296, 311), match='(532) 172 17 43'>
<re.Match object; span=(312, 325), match='(0532)1721743'>
<re.Match object; span=(326, 340), match='(0532) 1721743'>
<re.Match object; span=(341, 353), match='(532)1721743'>
<re.Match object; span=(354, 367), match='(532) 1721743'>
<re.Match object; span=(368, 382), match='(532) 172 1743'>
<re.Match object; span=(383, 398), match='(0532) 172 1743'>
<re.Match object; span=(399, 413), match='0 312 213 2965'>
[Finished in 617ms]