Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regexp question

Status
Not open for further replies.

iranor

Programmer
Jun 17, 2004
174
CA
I have a string that looks like this:

$Data = 'Sometext {value1} text {value2} bla';

With a function, I replace {value1} with some text, but I don't replace {value2} and I want to remove that text.

I can't find the right regular expression to remove all { } with the text inside...

Tried $FormTable = ereg_replace('\{[a-z]\}', '', $FormTable);
 
would it not be easier to do a string replace? (bearing in mind the statement in the php manual
If you don't need fancy replacing rules (like regular expressions), you should always use this function instead of ereg_replace() or preg_replace().
[/code]
referring to str_replace

Code:
$Data = 'Sometext {value1} text {value2} bla';
$input = array('{value1}', '{value2}');
$output = array{'some new text', '');

echo str_replace($input, $output, $Data);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top