Reputation: 173
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]
Upvotes: 0
Views: 270
Reputation: 362
Just do it with some basic CSS:
$string = 'Lorem ipsum <span class="mark">z:000</span> dolor sit amet';
In the header, you will have something like this
<style type="text/css">
.mark{font-weight:bold;}
</style>
Upvotes: 1
Reputation: 36984
This should help
preg_replace("/(z:[0-9]{3})/", '<b>${1}</b>', $string);
Works for z:000 to z:999
Upvotes: 3
Reputation: 7277
$string = preg_replace("/z:[0-9][0-9][0-9]/", "<b>\\0</b>", $string);
Upvotes: 1
Reputation: 1264
Don't need regex, just need HTML formatting!
Encase your string in HTML bold tags:
$string = '<b>Lorem ipsum z:000 dolor sit amet</b>';
Upvotes: 0