VBTom
asked on
Regular expression woes
I want to find every occurance of a string and be able to replace it with a different string depending on a parameter passed. (Cryptic, I know)
<mytag=some parameter>stuff inside!</mytag> text inbetween <mytag=param again>more stuff even</mytag>
The problem I am having is that my code will give me "stuff inside!</mytag> text inbetween <mytag=param again>more stuff even" instead of each one seperately.
Here is my code:
$regexp="\[mytag\=([a-zA-Z 0-9 ]+)\]([[:graph:] ]+)\[\/mytag\]";
while(eregi($regexp,$messa ge,$regs)) {
if(str_replace(" ","",strtolower("Tom Apps com"))==str_replace(" ","",strtolower($regs[1])) ){
$message=eregi_replace($re gexp,"\\2" ,$message) ;
}else{
$message=eregi_replace($re gexp,"",$m essage);
}
}
echo $message;
Help if you can! :)
<mytag=some parameter>stuff inside!</mytag> text inbetween <mytag=param again>more stuff even</mytag>
The problem I am having is that my code will give me "stuff inside!</mytag> text inbetween <mytag=param again>more stuff even" instead of each one seperately.
Here is my code:
$regexp="\[mytag\=([a-zA-Z
while(eregi($regexp,$messa
if(str_replace(" ","",strtolower("Tom Apps com"))==str_replace(" ","",strtolower($regs[1]))
$message=eregi_replace($re
}else{
$message=eregi_replace($re
}
}
echo $message;
Help if you can! :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.