Dika Maheswara
Dika Maheswara

Reputation: 3

regex on phone number

Id like to capture user data which has the format

name phone address

I'm using the phone as the hook to identify the part before phone as name and part after it as address, the phone should have 6-12 digits and can have these characters as well "+()[]-. ". I tried this regex

(.*)\s([0-9]{6-12}[\+\s\(\)-\[\]\.]+)\s(.*)

But its not acknowledging the range part {6-12}. What am I doing wrong and is there a better regex approach ?

Upvotes: 0

Views: 66

Answers (1)

Turn
Turn

Reputation: 7020

The format for the braces is {6,12} not {6-12}.

Upvotes: 1

Related Questions