Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't make a proper regular expression

Status
Not open for further replies.

McBugzz

Programmer
Sep 17, 2002
90
JP
I need a pattern for use with eregi_replace() function which would look like this:

> something $the_word_I_need_to_mark something <

so that I could mark a keyword found in a string, except for keywords found inside a tag description so that the tags don't get screwed.

Thanx

P.S.
> [[:alnum:]]+ $keyword [[:alnum:]]+ < didn't work right
 
like this:)

<?php
$string='<b>stuff in here</b>title<div align=somewhere>blah blah';
$word=somewhere;
$result=preg_match(&quot;/$word/&quot;,$string);
if ($result==1){
$string=preg_replace(&quot;/$word/&quot;,&quot;<b>$word</b>&quot;,$string);
echo $string;
}else{
echo $string;
}
?> ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
well nearly .. I have strange ehoing noises in my head that say &quot;oooh Im sure he mentioned something about avoiding tags....&quot;

Its a start tho :) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
as I thought .....but the pub intervened so I'll be back later :)
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top