The analogue of a regular expression or reverse function str_replace

The question was asked: 6 years 12 months ago   views: 32

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: 20-06-2012 в 19:35:00

Answers   1

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