Making regular expressions bold

I have some coordinates on my site that are printed as:

z:000

I would like to have this (including the z) printed in bold. The coordinates are in a text string like so:

$string = 'Lorem ipsum z:000 dolor sit amet';

I think I have to do this with Regex, but I'm not getting it to work. The first part is fixed, so the parts of the regex are ^z: and [0-9]

Answers


This should help

preg_replace("/(z:[0-9]{3})/", '<b>${1}</b>', $string);

Works for z:000 to z:999


Need Your Help

How to use Ruby mixins as patches to classes

ruby metaprogramming mixins

I started looking into Ruby, since I am looking to a more dynamic alternative to Java.

graphviz: HTML nodes have extra box around it?

graphviz

I'm using HTML nodes for graphviz per my previous question. Why do I get the extra box around the outside, and how do I get rid of it? Also how do I make the figure smaller?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.