preg_match一个String,用于从字符串中获取某些数字

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) {}

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})

god, so here...sorry for editing. like this

$ratingString = "Durchschnittsbewertung: 4.65000 von 5 Sternen 20 Bewertungen Location bewerten";
preg_match ( "#(\d\.\d{2})#", $ratingString, $matches );
var_dump ( $matches );