This is the regex for Rwandan phone numbers, which can be used for MTN, Tigo, or Airtel.
Use this regular expression to validate a mobile phone number input string in Rwanda in your code. The regular expression can be used in any programming language or text editor that supports regex.
The regular expression is: /^\+?(25)?0(\s)?-?7(\d){2}(\s|-)?(\d){3}(\s|-)?(\d){3}$/g
/^
: Denotes the start of the input string\+?
: Matches an optional plus sign(250)?
: Matches an optional country code (250) for Rwanda(\s)?
: Matches an optional space character\-?
: Matches an optional hyphen character0?
: Matches an optional leading zero7(\d){8}
: Matches the 9 digits of the mobile phone number (the first digit must be 7)$/g
: Denotes the end of the input string and the global flag for finding multiple matches.
Here are some resources that were used to create and test this regular expression: