What is the correct/standard syntax for preg_match regular expressions
-
17-06-2021 - |
Pergunta
I keep seeing variations with the delimiters of a preg_match including:
- preg_match("/[xxx]/",$foo)
- preg_match("/^[xxx]$/",$foo)
preg_match("#[xxx]#e",$foo)
etc.
Why the variations and which one should be used?
Solução
They are all correct.
A delimiter (what you said is open/close tags) can be any non-alphanumeric, non-backslash, non-whitespace character. Ref.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow