Reputation: 10755
I need a reg-ex for a pattern in a text box where pattern be as follow :
+1245 here first always should be a plus sign (+) and rest of all 4 should be digits (0 to 9)
I have used the other available reg-ex on google but they are mostly for the complete phone number not for extension .
Upvotes: 0
Views: 195
Reputation: 521249
Try this regex:
^[+][0-9]{4}.*$
This will match a leading plus followed by exactly four digits, which can also be followed by anything else.
Upvotes: 1
Reputation: 82474
If your entire string is as described, use this pattern:
^\+\d{4}$
^
means the beginning of the string
\+
means + (escape the + sign)
\d{4}
means exactly 4 digits
$
means the end of the string
Upvotes: 0