Matching content between two point php regex -


i'm trying create regex replace

href="/test/any-word-here" 

with

href="/search/theword.html" 

i'm pretty new regex's i'm not sure i'm doing came this

preg_replace('[href="/test/]([a-za-z])\"', "href=\"/search/$2.html\"", $content); 

could me out?

you close. [] undesirable. need capture entire word , not 1 letter.

preg_replace('#href="/test/(\w+)"#', 'href="/search/\1.html"', $content); 

Comments

Popular posts from this blog

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -