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
Post a Comment