The analogue of a regular expression or reverse function str_replace

The question was asked: 6 years 10 months ago   views: 17

There is a function str_replace

$word = str_replace("s", "", $word);

Whatever was in the variable - str_replace will kick out the letter "s" if they are there.

Interested in its inverse function. Something like an analogue of regular expressions. i.e. let's say:

$slovo = "oewiu*f037hf0287uhf08quh8uqen0f7320fn";
$only = "h12}*"; // characters that need to leave
// dancing with a tambourine
$word = "*hhh2";

Prompt, how such to implement?

Asked: Max Max 20-06-2012 в 19:35:00

Answers   1

echo preg_replace('/[^h12}*]/', ", 'oewiu*f037hf0287uhf08quh8uqen0f7320fn');
Answered: kite kite 20-06-2012 в 19:40:09
thank you very much - Sergey Sergey 20-06-2012 в 19:49:05