PHP regex periods

php, regex

Solution

Since `.` is a special character, you need to escape it to have it literally, so `\.`.

Remember to also escape the escape character if you want to use it in a string. So if you want to write the regular expression `foo\.bar` in a string declaration, it needs to be `"foo\\.bar"`.

Problem

How do I put a period into a PHP regular expression? The way it is used in the code is: ``` echo(preg_match("/\$\d{1,}\./", '$645.', $matches)); ``` But apparently the period in that `$645.` doesn't get recognized. Requesting tips on how to make this work.

Original source