winart
asked on
Problem with regular expression
hi,
i have problem with regular expression in php..
suppose i want to create a search facility..
when user entered, for example : "artist+korean+pop",
it will begin a search using these 3 words as a keywords.
My problem is.. i don't know how to form a regular expression that match these criterias...
For that example, i will form "(artist|korean|pop)+(arti st|korean| pop)+(arti st|korean| pop)+".
Very silly heh? if there're 10keywords, it will grow too...
could somebody help me,plz...
i have problem with regular expression in php..
suppose i want to create a search facility..
when user entered, for example : "artist+korean+pop",
it will begin a search using these 3 words as a keywords.
My problem is.. i don't know how to form a regular expression that match these criterias...
For that example, i will form "(artist|korean|pop)+(arti
Very silly heh? if there're 10keywords, it will grow too...
could somebody help me,plz...
ASKER
that's not what i want..
the pattern "artist+korean+pop" means :
1. these string : "artist korean pop" is match.
2. string : "korean artist pop" is match too!
3. string : "pop artist korean" is match too!
i bet your solution just worked for the 1st possibilities,right?
thx anyway..
the pattern "artist+korean+pop" means :
1. these string : "artist korean pop" is match.
2. string : "korean artist pop" is match too!
3. string : "pop artist korean" is match too!
i bet your solution just worked for the 1st possibilities,right?
thx anyway..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that's my problem!
i think it is very silly to create a looping for thing like that..
cause there'll be too many possibilities..
there a simpler approach, right?
by using regular expression...
thx,
i think it is very silly to create a looping for thing like that..
cause there'll be too many possibilities..
there a simpler approach, right?
by using regular expression...
thx,
ASKER
sorry,
i've found the answer..
by using RE.
anyway, thx for helping me..
win
i've found the answer..
by using RE.
anyway, thx for helping me..
win
Why dont you match inidividual strings in a loop
$strs = split(" ", "artist korean php");
for($i=0;$i<sizeof($strs);
{
//match pattern with $strs[$i];
}
venkat.