1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Replacement Problem

Discussion in 'Programming' started by juhav7, Apr 29, 2022.

  1. #1
    Is there any way or program to solve this kind of replacement. I have the text file which contains:




    etc... and lot of other text

    I want to replace first --- with word1, second --- with word2, etc

    Those words can be any kind of words like flower, people, beer... but the brackets (<a></a><b></b>) are the same.
    Is it possible to make all replacements AT ONCE? And how?

    The program like PowerGREP maybe could do this but I don't know how.

    Thanks if you can help.
    juhav7, Apr 29, 2022 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Are the bold tags always going to be the next element? Is there a container you can hook those anchors off of without pissing clasess onto all the children?

    <div class="moveA2B">
    <!-- .moveA2B --></div>
    Code (markup):
    then for the scripting:
    for (let anchor of document.querySelectorAll("moveA2B a") {
      anchor.nextElementSibling.textContent = anchor.textContent;
    Code (markup):
    Though I would question why you'd be doing this. Moving anchor text to a sibling element seems very strange.
    deathshadow, Apr 30, 2022 IP
  3. mmerlinn

    mmerlinn Prominent Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Since you have a text file, just about any program that massages text files will do your job with a FOR/NEXT or DO WHILE/ENDDO loop.

    If it were me, I would write FoxPro function with a few lines of code to do the job. Same can be done with any other language supporting text files.
    mmerlinn, Apr 30, 2022 IP