user3920295
user3920295

Reputation: 909

Preg_match for exact phone number match

expected_Phone_number: (888) 888-8888
actual_phone_number: (888) 888-8888

How do I use Preg_match to check if the 2 numbers match.(I need to check if the 2 phone numbers match exactly)

Upvotes: 1

Views: 194

Answers (1)

user557597
user557597

Reputation:

If php supports \Q .. \E, something like

'~^\Q' . $phone_number_expected . '\E$~';  

otherwise regex escape the phone number

'~^' . preg_quote($phone_number_expected, '~') . '$~';  

or just do a string compare

Upvotes: 1

Related Questions