find and replace in html files

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
JBurger
Junior Coder
Posts: 33
Joined: Wed Nov 12, 2003 7:16 pm
Location: NY

find and replace in html files

Post by JBurger » Tue Dec 22, 2009 8:38 pm

I've been trying to do this for a while and can't figure out a way.

I am using regex in MS to clean up html files and add hyperlinks to them.

To index chapter sections in the html, I use regex to find the chapter names and write out the link.

Now when the html has more than one link named the same thing; say the html has three sections, in each section there is a chapter named "CHAPTER ONE". With regex, the script finds 3 instances of CHAPTER ONE and gives the same link to each 3 times. How to I make it so I get 3 different links.

The ms script
http://pastebin.com/m7aa566bb

The file
http://pastebin.com/m4dd12cc6
-Joe

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Dec 23, 2009 9:45 pm

You could use the Separate> function to "find" your string. Then reassemble the html in a loop replacing your original string with a new string that somehow includes a incrementing counter.

something like this... (untested)

Code: Select all

Separate>html,Chapter One,line
Sub>line_count,1
Let>kk=0
Let>newhtml=
Repeat>kk
  Add>kk,1
  Let>value=line_%kk%
  Concat>newhtml,%value%Chapter One _%kk%
Until>kk=line_count
add>kk,1
Let>value=line_%kk%
Concat>newhtml,%value%

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts