Greetings to all who have entered

Actually, on preg-replay, simple expressions no longer cause panic, but I cannot cope with extracting the price from the text:

$price = 'Цена данного товара равна 355,55 рублей'; 

those. looking for numbers + (comma or period) + numbers. The question is simple, can anyone tell me what to write in preg_replace to catch the necessary expression?

ps even as it is a shame to ask, like just 1 team

    1 answer 1

    The solution is quite simple:

     $price = 'Цена данного товара равна 355,55 рублей'; preg_match_all('#\d+[,.]\d+#', $price, $m); print_r($m); 

    Code on ideone.com

    • It is now clear how to do ', or.' . Thank! - frank
    • The dot symbol in square brackets can be omitted. In this context, it is perceived not as a class, but as a simple symbol - Johny
    • @Johny Right! - Opalosolo