What's this delimeter (^) in PHP regex functions
I am using the delimiter /..../
in regex and I am using the character ^
used to indicate the start of a line or negation when used in a character class. So when I came across the line below using ^....^
I was puzzled:
$t = "172,249,L,P";
preg_split("^,^", $t);
What does it mean if anything?
You can use several different delimiters to ensure that they are not escaped on your particular regex string:
http://php.net/manual/en/regexp.reference.delimiters.php
This code:
preg_split("^,^", $t);
matches this code:
preg_split("/,/", $t);
The use ^
as a delimiter for a regular expression and ^
as a metacharacter in a regular expression is unrelated.