Having problems getting a PHP regex to match.
Posted
by
dqhendricks
on Stack Overflow
See other posts from Stack Overflow
or by dqhendricks
Published on 2011-01-01T23:29:15Z
Indexed on
2011/01/01
23:54 UTC
Read the original article
Hit count: 382
Here is my problem. It's probably a simple fix. I have a regex that I am using to replace a url BBCode. What I have right now that is not working looks like this.
<?php
$input_string = '[url=www.test.com]Test[url]';
$regex = '/\[url=(.+?)](.+?)\[\/url]/is';
$replacement_string = '<a href="$1">$2</a>';
echo preg_replace($regex, $replacement_string, $input_string);
?>
This currently outputs the original $input_string, while I would like it to output the following.
<a href="www.test.com">Test</a>
What am I missing?
© Stack Overflow or respective owner