Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few html files. The links on these files are mixed of upper case and lower case whereas the name of the file are all in lowercase.

I want to make the text inside href=".." lowercase whatever case they are now. Can anyone help me with this?

The number of file is over 4000. I would to love to do it from command line. I have used fart to replace text. FART is quite good for that. Is it possible to use any preg_match to make it work? Thanks in advance.

share|improve this question

So it is a one off thing for a lot of files.

I would use Notepad++ (free) or another text editor that allows find and replace using regular expressions.

  1. From the Menu, click Search --> Replace --> Find in Files.
  2. Make sure you check the "Regular expression" option.
  3. Add a filter if you can to speed things up (ie. *.html).
  4. In the "Find what:" box type (href=['"])(.+)(['"]).
  5. In the "Replace with:" box type \1\L\2\3.

This will find all href="[link-text]" or href='[link-text]' and replace it with itself but the [link-text] in lowercase.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.