Said Kaldybaev
Said Kaldybaev

Reputation: 9962

regex, test phone numbers ruby

Any phone numbers that begin with these ranges correct: ex: 772123322

The length is important, it should contain 6 digits at the end

550-559
700-709
770-779

so, i've done this so far:

\A(55[0-9])|(70[0-9])|(77[0-9])\d{6}\z

How can modify this regex to work properly ?

Upvotes: 0

Views: 126

Answers (2)

pguardiario
pguardiario

Reputation: 54984

Simpler is:

/^(55|70|77)\d{7}$/

Upvotes: 5

Themroc
Themroc

Reputation: 495

\A(55[0-9]|70[0-9]|77[0-9])\d{6}\z

Upvotes: 1

Related Questions