5

what is the meaning of the "~" in regex .For example in this code

preg_match("~^(\(\d+\)|\d+\-)?\d{10,20}$~",$value)

this code check for wether the phone number contains extension or not. I have tried to remove to the "~" in this code and got an error like this:

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in C:\xampp\htdocs\test\my_application\Phone.php on line 21

aleroot
  • 71,077
  • 30
  • 176
  • 213

1 Answers1

6

This character is called Tilde and in this case is simply a placeholder, it's just being used as a delimiter. It is simply delimiting the start and end of your regex pattern.

aleroot
  • 71,077
  • 30
  • 176
  • 213