Search code examples
javaregex

java regex for iraq phone number


I need a regex to match this phone number pattern:

  • it always starts with 07
  • then it is followed by a number from this range (3-9)
  • and it must be 11 chars

example : 07902848117

07796938209

07302819248


Solution

  • Try this, it should work.
    
    "07[3-9][0-9]{8}"  
    
    What this mean is,   
    07 - it tries to find literally 07  
    [3-9] - then followed by 3 to 9, only one time
    [0-9] - then followed by 0 to 9  
    {8} - text previous to this should has at least 8 characters.