Skip to main content
Known Participant
December 31, 2022
Answered

Wildcard Find/Replace (This is over my head.)

  • December 31, 2022
  • 2 replies
  • 1985 views

I want to change (in multiple files): 

<div></div><h1>Page Title</h1>

to

<div><h1>Page Title</h1></div>

 

 So I tried to Find:

<div></div><h1>[^"]*</h1>

 

and Replace with:

<div><h1>[^"]*</h1></div>

 

The [^"]* is something I found on find/replace help pages. Using a simple * or \* didn't find it. 

 

Dreamweaver found the correct string of code and moved the </div> where I needed it, but it literally replaced the title with [^"]*

 

The find only worked when "use regular expressions" was selected. Otherwise, it doesn't find it at all. 

 

Almost everything I've read about wildcards is way over my head, so please make sure you dumb down your answers for me. I've wasted so much time on this, I could have changed 50 pages by hand already. Just seems like using a wildcard should be so much easier than this. Hopefully I'm missing something very simple. Thanks!  

    This topic has been closed for replies.
    Correct answer L e n a

    The only thing this code leaves out is the caption below the image. There's a <br>, then a link to the artist. After that closing </a>, I'd like to put the </div>. Problem is, not every image has a caption, so I might be better off using the code you gave me and just moving the closing </div> by hand to the end of any caption (I have to open every page anyway and I'm down to 28 pages with images on them now, so this won't take much longer.)

     

    I really appreciate all your help with this. 


    I propose a not very elegant method, but I fear the case where you will have several identical images within the same page, or images that doesn’t have links below them

     

    anyway give a try with this expression (this one doesn’t handle different folder's name, just spells)

    (<img src="../images/spells/[\s\S]*?(?=</a>)</a>)

     

    on the other hand, make a BACK-UP of your local site, just in case... well, it would still be recoverable, but you might as well avoid too much inconvenience 😉

    2 replies

    Community Expert
    December 31, 2022

    you’re almost fine, just change your searching REGEX by

    <div></div><h1>(.*?)</h1>

    And then replace your destination string by

    <div><h1>$1</h1></div>

     

    The parenthese will isolate the unchanged group, and named then by $1

    The lazy char ? will stop the previous group when the next hard string will be found

    Well, that should do the tricks

    Community Expert
    January 1, 2023

    Cool, I'm glad it helped you, you're welcome!
    Is this the way it is, or would you like me to try to explain differently for you to understand the expression ?

    Known Participant
    January 4, 2023

    I propose a not very elegant method, but I fear the case where you will have several identical images within the same page, or images that doesn’t have links below them

     

    anyway give a try with this expression (this one doesn’t handle different folder's name, just spells)

    (<img src="../images/spells/[\s\S]*?(?=</a>)</a>)

     

    on the other hand, make a BACK-UP of your local site, just in case... well, it would still be recoverable, but you might as well avoid too much inconvenience 😉


    Thanks for all the help, Lena! At the moment, I'm done with my 600+ page conversion to CSS. As usual, I didn't receive a notification that you had replied, so I ended up finishing the last 30 or so images with the code you provided previously, simply moving the </div> to the end of the artist credit on the ones where it was needed. It was a tedious job (the entire conversion, not just that bit), but I'm finally finished! Maybe Google will put me back in the listings now that I'm not a grumpy, old FrontPage site anymore, lol. I sincerely appreciate your help. You're really good at this! 

     

    Best wishes,

    Heather 

    Nancy OShea
    Community Expert
    Community Expert
    December 31, 2022

    How big is your site? 

    I ask because there should be only 1 <h1> tag per document.  Therefore, I would search for all <h1> titles</h1> and select FIND ALL. 

    Systematically click on each Result and adjust <div> nesting as required.   Rinse, lather, repeat.

     

    Nancy O'Shea— Product User & Community Expert
    Known Participant
    December 31, 2022

    I have about 250 pages left to go through. So a find/replace would be most helpful. I would have done them by hand if there were only 10-20 pages. But yes, there's only one H1 per page. 

    Nancy OShea
    Community Expert
    Community Expert
    December 31, 2022

    OK try this:

    Ctrl + Shift + F to bring up Find & Replace.  Advanced Tag.  NOTE: I highly recommend doing this in a test document to ensure it works as desired BEFORE applying to your entire site.  Assuming each Page Title is unique, I'm using JavaScript to grab contents from your document's <title> tag.  See screenshot.

     

     

    Hope that helps.

     

    Nancy O'Shea— Product User & Community Expert