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 expression
Because 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
backslash
characters 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/(.+?").+>\KBild
REPLACE
<img src="./pdfs/pics/\1 alt="Bild" align="middle" height="80" width="60">
with the options
Wrap around
andRegular expression
checked and a click on theReplace All
button, 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
\Q
and\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
\Q
at that point an no “closing”\E
is needed!Example, find a minimal run of any characters followed by 3 literal
*
:.*?\Q***