none
Find and Replace: use of wildcards RRS feed

  • Question

  • Hello all,

    Was wondering if there is a way to specify wildcards in the Replace function in EW?
    For example, code might contain <p class="MainHeader"> xxx </p> (where xxx can be any text) which I am wanting to globally replace to <h2> xxx </h2>

    Thanks,
    Martin


    Stabes

    Monday, April 11, 2016 11:41 AM

Answers

  • Yes, you can.  But first - which version of EW are you using?  What you are asking is easy using the HTML tags tab of find/replace, and using HTML rules.  I'm not sure which versions those were in.  (I'm looking at EW4.)

    If you do have those, use Edit -> Replace to open the Find and Replace window, and go to the "HTML Tags" tab.

    Then, in that window:

    Find tag:  (select p)
    Click "HTML Rules..."
    Click "New rule..."
    In the dropdown list that appears, select "With attribute".
    In the new dropdowns that appear, select the attribute (class), leave "Equals", and type in the value, MainHeader.
    Click OK.
    Replace action:  (select Change tag)
    To: (select h2)

    Replace all.

    You now have <h2 class="MainHeader">, but you don't want the class there, so:

    Still in the HTML Tags window, switch the Find tag: to h2.
    If you haven't deleted it, you still have the HTML rule "With attribute class = MainHeader".  (You can check by clicking "HTML Rules...".)
    Set the "Replace action:" to "Remove attribute".

    Replace all.

    You now have <h2> opening and closing tags where you used to have <p class="MainHeader"> opening and closing tags.



    Kathleen Wilber
    BrightWillow - ASP.NET applications


    • Edited by KathyW2 Monday, April 11, 2016 5:55 PM
    • Marked as answer by Stabes Tuesday, April 12, 2016 7:57 AM
    Monday, April 11, 2016 3:22 PM

All replies

  • Yes, you can.  But first - which version of EW are you using?  What you are asking is easy using the HTML tags tab of find/replace, and using HTML rules.  I'm not sure which versions those were in.  (I'm looking at EW4.)

    If you do have those, use Edit -> Replace to open the Find and Replace window, and go to the "HTML Tags" tab.

    Then, in that window:

    Find tag:  (select p)
    Click "HTML Rules..."
    Click "New rule..."
    In the dropdown list that appears, select "With attribute".
    In the new dropdowns that appear, select the attribute (class), leave "Equals", and type in the value, MainHeader.
    Click OK.
    Replace action:  (select Change tag)
    To: (select h2)

    Replace all.

    You now have <h2 class="MainHeader">, but you don't want the class there, so:

    Still in the HTML Tags window, switch the Find tag: to h2.
    If you haven't deleted it, you still have the HTML rule "With attribute class = MainHeader".  (You can check by clicking "HTML Rules...".)
    Set the "Replace action:" to "Remove attribute".

    Replace all.

    You now have <h2> opening and closing tags where you used to have <p class="MainHeader"> opening and closing tags.



    Kathleen Wilber
    BrightWillow - ASP.NET applications


    • Edited by KathyW2 Monday, April 11, 2016 5:55 PM
    • Marked as answer by Stabes Tuesday, April 12, 2016 7:57 AM
    Monday, April 11, 2016 3:22 PM
  • Thanks Kathy. Just brilliant. Pretty powerful tool when you know how to use it properly :-)

    Martin


    Stabes

    Tuesday, April 12, 2016 7:58 AM