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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -