preg_replace PHP - / or @, why put?

3

Using preg_replace () in PHP, I came across the following situation:

echo preg_replace('/:([\w]+)/', 'batata', ':quiabo/isso/:nada');

echo preg_replace('@:([\w]+)@', 'batata', ':quiabo/isso/:nada');

Both expressions print the same thing: potato / this / potato

From this I have two doubts:

1 - Why do we need to use '/' or '@' at the beginning of the pattern?

2 - What's the difference between using '/' or '@' in this same situation?

    
asked by anonymous 22.04.2015 / 22:36

1 answer

2

No difference, just to indicate the start (delimiters) and end of your regex

Update:

Just in case you want to marry a '@' there would have to escape using the delimiters @

ex.

@\@@

or

/@/
    
22.04.2015 / 22:39