Search code examples
phpregexirc

Regular expression to match time and IRC-Nick


I'm not very experienced in regular expressions and I tried a lot to match a string like this:

16:02 <DJ_Bjarne>

with a regex, but I didn't get any working result. I want this to be replaced by

<strong>16:02&lt;DJ_Bjarne&gt;</strong>

with a regex that works in PHP. Thank you.


Solution

  • $post = "16:02 &lt; DJ_Bjarne&gt; hello mate!";
    preg_replace("/(.*?&gt;)/", "<strong>$1</strong>", $post);