function removeQuotes($string){
$noQuotes = str_replace('"','', $string);
return $noQuotes
}
//to call the function, on a string $iHaveQuotes
$iHaveQuotes = 'I Have """ Quotes!!!';
$iHaveQuotes = removeQuotes($iHaveQuotes);
//$iHaveQuotes now is equal to 'I Have Quotes!!!'
$text="hello i am text="hello"
how are you doing text="buuhu"
what text="sefdsf"dfsfsdf"
sdfsdfd text=""freak" sdf"";
$new_text=replace_quotes((look for " within text="") ,'', $text);
echo $new_text;
//--> results -->
//hello i am text="hello"
//how are you doing text="buuhu"
//what text="sefdsfdfsfsdf"
//sdfsdfd text="freak sdf"
joachimseitz wrote:gives me this error: Parse error: syntax error, unexpected '*' in .../quotes.php on line 7
i expect:
sdfsdfd text="freak sdf"
will be the result
Well, that is the result. Create a file with only that single line I posted, and you'll see that it is correct. You apparently didn't implement my suggestion properly.
joachimseitz wrote:but I need the whole text to be searched ...
First get that single line I posted working. Then (try) to understand how (and why) it works. Finally expand on that to do all the replacements in your text.
Yes I have gotten it to work now. I don't actually know why it didn't work the first time. I did the same thing, copy and past in a file :/ (and yes its line seven because i had some old variables on the top but they are there now to and it works now anyways weird)
$text='hello i am text="hello"
how are you doing text="buuhu"
what text="sefdsf"dfsfsdf"
sdfsdfd text=""freak" sdf"';
$text= preg_replace('/(?<!=)"(?![^"]*=)/', 'QUO_TES', $text);
//from http://www.webmasterworld.com/php/3853648.htm (third post)
$text = preg_replace('/QUO_TES(?![^QUO_TES]+QUO_TES)/','"',$text);
//$text= preg_replace('/QUO_TES/', '', $text); im guessing str_replace is faster but both work
$text= str_replace('QUO_TES', '', $text);
echo $text;
//hello i am text="hello" how are you doing text="buuhu" what text="sefdsfdfsfsdf" sdfsdfd text="freak sdf"