Issue
Substitute "s|<a(.*)href=\"/(.*)\.html\"(.*)>|<a$1href=\"/$2\"$3>|i"
This is the substitute rule I'm using but looks like if in a paragraph I have more than one hrefs, only the trailing one is stripped out the html extension. Previous hrefs have no impact.
Solution
The (.*)
means as many chars from this line as possible, so after matching the first <a
, it will search for the farest href
following. If you add a ? after the *, it will look for the smallest string matching (.*?)
that still allows the rest to match.
Substitute "s|<a(.*?)href=\"/(.*?)\.html\"(.*?)>|<a$1 href=\"/$2\"$3>|i"
Answered By - Eily Answer Checked By - David Marino (WPSolving Volunteer)