Reputation: 23
I'm trying to change a lot of URLs with TextWrangler, those ending with m.htm
should lose the m
, but only if the total number of characters in the filename is 7. Those with fewer characters should not be changed.
I've tried
/.*?{7}m.htm/
but it doesn't work...
What is the solution?
Upvotes: 2
Views: 2534
Reputation: 5774
Replace
href="([^"]*)\/(.{6})m.htm([^"]*)"
Meaning : href="
followed by any non "
character until a /
(the latest the better: greedy) then 6 character followed by a m
, then any non "
character.
By
href="\1\/\2.htm\3"
Meaning :
\1 = [^"]*
\2 = .{6}
\3 = [^"]*
Example
<a href="google.com/foo/bar/urzadjm.htm">testM</a>
\1 : google.com/foo/bar
\2 : urzadj
\3 : <empty>
If files can be htm
and php
, I suggest to replace .htm
by (.htm|.php)
(!Warning to back-references change in numbers!)
Upvotes: 2
Reputation: 136435
May be
/\b.{6}m\.htm/
That is, starting on the word boundary, followed by any 6 symbols, followed by m.htm.
Upvotes: 0