Help for mass replacement.
-
Hello.
I need help!
There is a design type:
<a href=“/wp-content/uploads/2018/10/2-2.jpg”><img src=“/wp-content/uploads/2018/10/2-2.jpg” alt=“Ergobag1111” width=“1000” height=“708” class=“aligncenter size-full wp-image-21814” /></a>
<a href=“/wp-content/uploads/2018/10/3-2.jpg”><img src=“/wp-content/uploads/2018/10/3-2.jpg” alt=“Ergobag2222” width=“1100” height=“652” class=“aligncenter size-full wp-image-21815” /></a>
<a href=“/wp-content/uploads/2018/10/4-2.jpg”><img src=“/wp-content/uploads/2018/10/4-2.jpg” alt=“Ergobag3333” width=“1200” height=“497” class=“aligncenter size-full wp-image-21816” /></a>
We need to redo it into the next view:
<a href=“/wp-content/uploads/2018/10/2-2.jpg” class=“item” style=“background-image: url(‘/wp-content/uploads/2018/10/2-2.jpg’)” data-alt=“Ergobag1111” ></a>
<a href=“/wp-content/uploads/2018/10/3-2.jpg” class=“item” style=“background-image: url(‘/wp-content/uploads/2018/10/3-2.jpg’)” data-alt=“Ergobag2222” ></a>
<a href=“/wp-content/uploads/2018/10/4-2.jpg” class=“item” style=“background-image: url(‘/wp-content/uploads/2018/10/4-2.jpg’)” data-alt=“Ergobag3333” ></a>
I tried to make it a team:
(“><img src=”)|(" width=“." height=".” class=“.* /></a>)|(” width=“." height=".” class=".* /></a>)
(?1" class=“item” style=“background-image: url(‘)(?2’)” data-alt=“)(?3” ></a>)
But it does not work correctly.
I want to do exactly that the replacement occurred as a team.
Please, help!
-
Hello, владимир-антониковn, and All,
Assuming that your XML text uses :
-
Regular Simple quote (
'), of Unicode value\x{0027}, and not the characters‘and’ -
Regular Double quote (
"), of Unicode value\x{0022}, and not the characters“and”
These changes of text can be easily done with regular expressions :-))
-
Open the Replace dialog (
Ctrl + H) -
SEARCH
><img src="(.*?)"\x20(alt=".+?").+?\x20/(></a>) -
REPLACE
\x20class="item"\x20style="background-image:\x20url\('\1'\)"\x20data-\2\x20\3 -
Tick, preferably, the
Wrap aroundoption -
Select the
Regular expressionsearch mode -
Click, once on the
Replace Allbutton or several times on theReplacebutton
Et voilà !
If OK, I’ll give you some explanations on that regex S/R, next time
Best Regards
guy038
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login