note 113352 deleted from regexp.reference.meta by salathe
| From: | salathe@php.net | Date: | Tue, 21 Oct 2014 12:31:50 +0000 |
| Subject: | note 113352 deleted from regexp.reference.meta by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200703@lists.php.net to get a copy of this message | ||
Note Submitter: ruben dot santacruz at gmail dot com
----
Note that if you want to match the dollar character and you are using a double quoted string for
defining the pattern, you should use \$ but you need to escape both the backslash and the dollar
sign itself.
This is because inside a double quoted string PHP will interpret the \$ sequence as a single $
character.
Example:
To match "$5.00" in "I owe you $5.00 exactly", the "/\$5\.00/" pattern
will become "/$5\.00" that it is not the desired pattern. It should be
"/\\\$5\.00/" that will become "/\$5\.00/".
My recommendation is to always keep this in mind or use single quoted strings, because single quotes
has less escape sequences interpreted.