• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Dec 31, 2022 Dec 31, 2022

Copy link to clipboard

Copied

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!  

Views

490

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 4 Correct answers

Community Expert , Dec 31, 2022 Dec 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

Votes

Translate

Translate
Community Expert , Jan 03, 2023 Jan 03, 2023

This kind of search and replace should be possible through the search in files function (Ctrl | Cmd + Shift + F),  then using the advanced tab of DW, but since the topic of this thread is based on REGEX, I propose that we continue with the use of REGEX.

 

In fact, this is the same query as used before.

In the search field enter :

(<img.*?>)

In summary, we search for the string <img followed by any characters (using the dot) and this as many times as necessary (because of the star), but with the

...

Votes

Translate

Translate
Community Expert , Jan 04, 2023 Jan 04, 2023

You don't have to apologize, you know, we all run somewhere and time still flies 😉 The Floyd sang that, wonderfully, a few years ago.

 

Well, it seems that your page images are all contained in a folder called spells, itself contained in a folder called images

 

So, did you tried to replace the search query with

(<img src="../images/spells/.*?>)

That should do the job

If that desn’t match, probably that you will have to escape the slash character / using a back slash \ as :

(<img src="..\/image
...

Votes

Translate

Translate
Community Expert , Jan 04, 2023 Jan 04, 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 😉

Votes

Translate

Translate
Explorer ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

LATEST

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines