I have a feeling that I might be missing something very basic. Anyways heres the scenario:
I'm using preg_replace to convert ===inputA===inputB===
to <a href="inputB">inputA</a>
This is what I'm using
$new = preg_replace('/===(.*?)===(.*?)===/', '<a href="$2">$1</a>', $old);
Its working fine alright, but I also need to further restrict inputB so its like this
preg_replace('/[^\w]/', '', every Link or inputB);
So basically, in the first code, where you see $2
over there I need to perform operations on that $2
so that it only contains \w
as you can see in the second code. So the final result should be like this:
Convert ===The link===link's page===
to <a href="linkspage">The link</a>
I have no idea how to do this, what should I do?