Searching for, marking and replace in one Line
-
Hello here… I coud need your help.
I have the following line :
<A HREF=“./pdfs/pics/1400_Days.jpg” target=“_gnnnfigte”>Bild</A>
From this Line i would do the following :
Searching for “<A HREF=”./pdfs/pics/"
Marking the Text behind : (in every Line different) 1400_Days.jpg
Searchin for “Bild”
Replace Bild with :<img src="./pdfs/pics/THE-MARKED-TEXT"alt=“Bild” align=“middle” height=“80” width=“60”></A>So that after all the complete Line looks like this :
<A HREF=“./pdfs/pics/1400_Days.jpg” target=“_gnnnfigte”><img src=“./pdfs/pics/1400_Days.jpg” alt=“Bild” align=middle height=“80” width=“60”></A>
How can i get this , repeating for over 100 Lines ???
regards Daniel
-
With the given data, one possible solution might be
find what:<A HREF="\./pdfs/pics/.*">\KBild
replace with:\<img src="\./pdfs/pics/1400_Days\.jpg" alt="Bild" align=middle height="80" width="60"\>
checkRegular expressionBecause of using the \K syntax it is needed to press replace all.
-
Hello, @daniel-rafflenbeul, @ekopalypse and All,
@ekopalypse, I don’t think the different
backslashcharacters are necessary in the Replace zone !However, as @daniel-rafflenbeul said
Marking the Text behind : (in every Line different) 1400_Days.jpg
I suppose that we have to catch every picture’s name !.
So, I propose the following regex S/R :
SEARCH
(?-s)<A HREF="\./pdfs/pics/(.+?").+>\KBildREPLACE
<img src="./pdfs/pics/\1 alt="Bild" align="middle" height="80" width="60">with the options
Wrap aroundandRegular expressionchecked and a click on theReplace Allbutton, exclusivelyBest Regards,
guy038
-
-
@Ekopalypse said in Searching for, marking and replace in one Line:
maybe because I’m currently working on this.
+1 ! :-)
I always escape them if they are used literally, just to be sure.
or you could wrap them in
\Qand\E, for a cleaner look as a side benefit! -
that’s really a nice one.
\Q…\E is much easier than parsing through the string :-D -
@Ekopalypse said in Searching for, marking and replace in one Line:
\Q…\E is much easier
and it is even easier if the regex string is intended to be all literal after a certain point. Just use
\Qat that point an no “closing”\Eis needed!Example, find a minimal run of any characters followed by 3 literal
*:.*?\Q***
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