Hi.. Please solve the below regex problem and will pay $5 through paypal!! $data="asd<br>asd asd<b>anti spyware for mac</b> asd asdas free mac spyware das d<b>ret from mac spyware remover to mac home</b>"; $srch="free mac spyware"; $regex = "/.*<b[^>]*?>(.*?.'.$srch.'.*?)<\/b>/i"; preg_match($regex,$data,$matches); It is not matching properly and it outputs, <b>anti spyware for mac</b> asd asdas free mac spyware das d<b>ret from mac spyware remover to mac home</b>"; Required Output is: Nothing!!! Null because it is not present in <b></b> tags If the $srch="mac spyware remover"; Then Required Output is: ret from mac spyware remover to mac home Or, if you are able to provide another EFFICIENT solution as a reusable function to perform the task, it is also appreciable Regards Jawahar
basically i want to find if a specific word appears in BOLD TAG or not. Similarly for Anchor TAG also!!`
<?php $data="asd<br>asd asd<b>anti spyware for mac</b> asd asdas free mac spyware das d<b>ret from mac spyware remover to mac home</b>"; $srch="mac spyware remover"; $regex = "/<b\s*?>([^<]*?" . $srch . ".*?)<\/b>/"; preg_match($regex,$data,$m); echo '<pre>'; print_r($m); ?> PHP:
qprojects: If there are any other tags inside <b> it will not match :-( No Problem !! Thanks guys.. I have solved this by doing a preg_match_all and getting all B tags and then matching with a for loop !! THREAD CLOSED !