Last active
December 16, 2015 10:49
-
-
Save dcsg/5423255 to your computer and use it in GitHub Desktop.
Search inside a string for a regex expression and output the matches with some modification (in this case in bold)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$expression = 'here we got a number 23 % and so on'; | |
$pattern = '/(\d+ %)/'; | |
$replacement = '<b>$1</b>'; | |
echo preg_replace($pattern, $replacement, $expression); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment