Replace only A-Z/0-9 using ereg_replace();
I'm using a PHP version earlier than 5.3.0.
I have a series of stock numbers on a page, that I need to detect and replace. The pattern of each stock number are letters and numbers, containing a period somewhere in between, and possibly a dash.
The code I have works to detect the stock numbers, however they include the HTML tags if they are not separated by a space.
PHP Code:
$text = "<strong>34D-23.48</strong>";
$text = ereg_replace("([a-zA-Z0-9]+.+[a-zA-Z0-9])",
"Stock # \\0", $text);
echo $text;
However, the resulting HTML outputs as this:
Code:
<Stock #strong>34D-23.48</strong>
I can't separate the stock numbers, how do I get it so the output is like this?
Code:
<strong>Stock #34D-23.48</strong>
Thanks in advance for the help. :]
-Josh