Oct 4, 2001, 10:13 AM
Post #2 of 3
Suppose your html string is stored in a file called replace.txt then the follow one line code should solve your problem:
Re: Regex to insert associate ID into link
[In reply to]
perl -ne "$pos = index ($_, 'qid'); pos ($_)=$pos; s/qid=(.*?)\//ASIN\/0805063773\/associate id/g; print" replace.txt
we first use index to find out the qid position and then reset the position pointer by using pos function. From there, we can use s//g to replace the string to the desired string. the /g modifier has to be added to make the position pointer change in effect. The other stuff should be pretty clear to you now!!