Skip navigation
Currently Being Moderated

Regex: Remove Date from File Names Sitewide

Apr 15, 2013 5:25 AM

I'm trying to avoid  hundreds of 301 redirects across my site. I have two kinds of links that need a regex search string which will simply remove numbers that precede text within html files.

 

The existing .html files are named with text only (e.g., name.html), whereas the .jpg files have the date and text (e.g., 130415name.jpg). But the new html engine I am using creates files named like the .jpg files (e.g., 130415name.html).

 

I can strip the numbers out of file names in Name Munger (Strip Characters > Characters: 0123456789).

 

Now I need a regex search string that will strip the same characters within the html files.

 

The changes would look like this:

 

1.

 

Before:

 

<ul>

<li class="previous"> <a class="paginationLinks detailText" href="../content/090914name.html">Previous</a> </li>

<li class="index"> <a href="../index_4.html" class="detailLinks detailText">Index</a> </li>

<li class="next"> <a class="paginationLinks detailText" href="../content/090125name.html">Next</a> </li>

</ul>

 

After:

 

<ul>

<li class="previous"> <a class="paginationLinks detailText" href="../content/name.html">Previous</a> </li>

<li class="index"> <a href="../index_4.html" class="detailLinks detailText">Index</a> </li>

<li class="next"> <a class="paginationLinks detailText" href="../content/name.html">Next</a> </li>

</ul>

 

2.

 

Before:

 

onclick="window.location.href='content/020922name.html'"

 

After:

 

onclick="window.location.href='content/name.html'"

 

What is the regex search string for these examples (any numbers preceding any letters preceding .html)?

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points