Newmaster
Newmaster

Reputation: 57

Two regex pattern in to one

Patterns is working fine but i want them in one regex patter:

$reg_data['phone']  = preg_replace('/[\s\(\)]+/', '', $reg_data['phone']);
$reg_data['phone']  = preg_replace('/^\+998/', '', $reg_data['phone']);

Upvotes: 0

Views: 45

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174696

Use an alternation operator |.

$reg_data['phone']  = preg_replace('~[\s\(\)]+|^\+998~', '', $reg_data['phone']);

Upvotes: 2

Related Questions