Using OR/AND in preg_replace ?
Posted: Thu Jul 08, 2010 8:23 am
Hi
I want to use two lines for on string in preg_replace..
I want the following two codes to work:
The difference between them is that the second one got space between ":" and "([a.."
The problem I am trying to solve is this..
When I use the first line of code and type in "keyword: wordkey" it echo "keywordwordkey" instead of "keyword" as it shuld and does when I enter "keyword:wordkey" (without the space).
When I am using the other line of code and type in "keyword:wordkey" it echo "keyword:wordkey" and not "keyword" is it shuld and does when I enter "keyword: wordkey" (with the space).
What I want is that it echos "keyword" no matter if there is a space there or not ..
Does anyone know how to fix this?
Thanks in advance
I want to use two lines for on string in preg_replace..
I want the following two codes to work:
Code: Select all
$shop = preg_replace('/:([a-zA-Z0-9]*(\s){0,1})/','',$search);Code: Select all
$shop = preg_replace('/: ([a-zA-Z0-9]*(\s){0,1})/','',$search);The problem I am trying to solve is this..
When I use the first line of code and type in "keyword: wordkey" it echo "keywordwordkey" instead of "keyword" as it shuld and does when I enter "keyword:wordkey" (without the space).
When I am using the other line of code and type in "keyword:wordkey" it echo "keyword:wordkey" and not "keyword" is it shuld and does when I enter "keyword: wordkey" (with the space).
What I want is that it echos "keyword" no matter if there is a space there or not ..
Does anyone know how to fix this?
Thanks in advance