I am trying to build a regular expression for some checks within my PL/SQL code (so i am using Oracle Database which can use (POSIX) standard draft 1003.2/D11.2).
I want to match all variants of inputs which could be a phone number. I already have created this regular expression:
[+0-9][0-9- ()_]{4,20}
The only problem i have (to get what i want to have) is: If there is any letter within the input string which will be tested by my regular expression, the regular expression will have a match after and/or before the letter.
Example 1:
Input: " 044-d4(54)1-_14455"
Match: "4(54)1-_14455"
--> "d" within the number --> there should be no match
Example 2:
Input: "044444-d4(54)1d-_14455"
Match1: "044444-"
Match2: "4(54)1"
Match3: "14455"
--> two "d" within the number --> there should be no match
Example 3:
Input: "+904 4-4(54)1-_14455"
Match1: "+904 4-4(54)1-_14455"
--> correct! I want this one to be matched.
I just want to modify my regular expression that way, that it will not return a match, if there are any letters within the phone number. All the other special characters like _-/() are ok to have.
I already googled, but i am no expert at regular expressions, so all my tries where not successful...
You can use start of the string (^) and end of the string ($), in your regex.
^[+0-9][0-9- ()_]{4,20}$