Regular expression


I am learning how to use regular expressions, I followed some tutorials and my regex works up to some point and would like some help on it, basically if I have a text in the form of

this is the sample text: {|plugin|fbcomm|fr_FR|350|} and bellow is the regex
$regex = “{\|plugin\|\w{6}\|[a-z]{2}_[A-Z]{2}\|\d{3}\|}”;

PHP does find and replace everything except the {}, I tried excaping those with a slash but then I get an error: Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in

the function I am using is this $text = preg_replace( $regex, “”, $text);

any help is appreciated

try the following code:


$str = "{|plugin|fbcomm|fr_FR|350|}";

echo "\
Input: ";

echo "\
Replacing text...";
$str = preg_replace("#^\\{\\|plugin\\|[a-z]+\\|[a-z_]{5}\\|\\d+\\|\\}$#i", "", $str);

echo "\
Output: ";



The output of the script is:

Input: string(27) “{|plugin|fbcomm|fr_FR|350|}”
Replacing text…
Output: string(0) “”

thank you, that does work however I still needed to modify it because of my needs, at the end this is how I made it