preg_match a String to get certain numbers out of the string
php, regex
Solution
You need to escape the dot as dot is special character in regex which matches any character if not escaped:
^(\S*\s)(\d\.\d{2})
Problem
I have a string that always has the following format `Text: 1.1111111 Text` What I need is `1.11` of the string So I went with this regex `^(\S*\s)(\d.\d{2})` I've used http://regex101.com/ to try it out and it works there, but when I do it on my own code, the matches array is always empty. This is the code ``` //$ratingString = Durchschnittsbewertung: 4.65000 von 5 Sternen 20 Bewertungen Location bewerten preg_match ( "/^(\S*\s)(\d.\d{2})/", $ratingString, $matches ); var_dump ( $matches ); // matches == array (0) {} ```