Take the 2-minute tour ×

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


but it doesn't work...

What is the solution?

share|improve this question
Can you provide 2 urls you want to change (with the replacements) and two you don't want to change? –  M'vy Mar 28 '11 at 9:06
here is the syntax for the four urls, first and fourth need to be changed, second and third need no changes <a href="google.com/urzadjm.htm">testM</a> <a href="google.com/brblam.htm">test</a> <a href="google.com/rlfzao.htm">test</a> <a href="google.com/vlabgam.htm">testM</a> –  liz Mar 28 '11 at 9:18
Do you already have the URL at your disposition, or you have all the <a> block to parse? –  M'vy Mar 28 '11 at 9:29
this is the syntax from the file I'm working on, unfortunately I can't work with just a list of plain urls (if that's what you mean?) –  liz Mar 28 '11 at 9:33
add comment

2 Answers

up vote 1 down vote accepted



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.



Meaning :

\1 = [^"]*
\2 = .{6}
\3 = [^"]*


<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!)

share|improve this answer
this does find the strings I want, but it doesn't remove the m, it just pastes the same string... –  liz Mar 28 '11 at 9:59
Oh my bad!! I made a mistake with the parenthesis. Corrected. –  M'vy Mar 28 '11 at 10:00
it seems I got it, had to move the m out of the second group! :) –  liz Mar 28 '11 at 10:01
Thank you very very much! It works :) –  liz Mar 28 '11 at 10:06
add comment

May be


That is, starting on the word boundary, followed by any 6 symbols, followed by m.htm.

share|improve this answer
Doesn't work, and TextWrangler doesn't even give me any error message... –  liz Mar 28 '11 at 9:14
What flavour of regex does TextWrangler undestand? –  Maxim Yegorushkin Mar 28 '11 at 9:20
How can I find it out? I haven't installed any add-ons or anything, if that helps... –  liz Mar 28 '11 at 9:27
Interesting. This doesn't work in Vim either. Not sure why.. –  Mongus Pong Mar 28 '11 at 9:36
add comment

Your Answer


