Menu

Placing Text Elsewhere in html document

SteveL
2013-05-28
2013-06-03
  • SteveL

    SteveL - 2013-05-28

    Ok...I am really having some trouble trying to figure this one out....hopefully someone will have an answer for me as I am still learning this.

    I have some text between tags that I need to copy and place between another set of tags on another line.

    Example:
    I have text between an H1 tag on line 30 that I want to take and put between H2 tags on line 20 and eliminate the text that was previously between the H2 tags and then delete line 30.

    Line 20: <h2>H2 Sample Text</h2>

    Line 30: <h1>H1 Sample Text</h1>

    Can someone tell me if this can be done?

     

    Last edit: SteveL 2013-05-28
  • cchris

    cchris - 2013-06-03

    I'd do this in several steps, using regular expressions

    1/
    Search:


    Replace with: <h0>
    2/
    Search: </h0>

    .*?


    Replace with:


    Check ". matches new line" box to capture multiline text
    3/
    Search:


    Replace with:

    At this point you have
    <h0>H2 sample text</h0>

    H1 sample text


    We are close.

    4/
    Search: <h0>
    Direction: backwards</h0>

    5/
    Search: <h0>.*?</h0>


    Replace with:


    Switch back to forward

    Only 2/ and 5/ equire regular expressions. In particular, 4/ won't work unless in normal mode.

    As you can guess, this can be recorded in a macro.
    CChris