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!

regex problems

Status
Not open for further replies.

safra

Technical User
Jan 24, 2001
319
NL
Hi,

If the > character occurs in a string, I would like to put the remaining of a string starting from character > in bold:

example:
$var = "beginning of string > end of string";

should become:
$var = &quot;beginning of string <b>> end of string</b>&quot;;

could anyone show me how to do this with ereg().

Thanks,
Ron
 
This should work:
$string = ereg_replace(&quot;(.*)(>.*)&quot;, &quot;\\1<b>\\2</b>&quot;, $string); //Daniel
 
Thanks, it did work!

But it seems that if more then one > occurs only the part from the last > is effected. How to effect everything from the first >?

Ron
 
Try this:
$string = ereg_replace(&quot;([^>]*)(>.*)&quot;, &quot;\\1<b>\\2</b>&quot;, $string); //Daniel
 
that's it, thanks a lot!

I was close but missed the brackets.

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top