php - preg_replace add links around words starting with some-part-of-a-word -
i've got preg_replace in php correctly replaces every word starting 'exploit' links:
preg_replace('#[\b]?(exploit([^ ]*))[\b]?#', '<a>$1</a>', 'my exploits exploitable.');
i this:
my <a>exploits</a> <a>exploitable.</a>
which half wrong, fullstop should not linked on second word. know need replace above part [^ ] [^\b] doesn't work.
i know can i.e [^ .] work on words ending space , fullstops, not commas example.
\b(exploit[a-za-z]*)
should trick.
aside: website pretty handy trying out preg_replace: http://www.fullonrobotchubby.co.uk/random/preg_tester/preg_tester.php
Comments
Post a Comment