preg_replace on the matches of another preg_replace

fompiskspoise

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