<a target="_blank" href="img_forest.jpg">
<img src="img_forest.jpg">
<img src="img_forest110.jpg">
<img src="img_forest228.jpg">
<img src="img_forest334.jpg">
&#13;
我需要复制行并更改
img
src为其他行的target="_blank"
href并保持img src值相同。
有办法吗?
答案 0 :(得分:2)
def estDiviseur(i,n):
return n%i==0
def estPremier(n):
b=0
if n==1:
return False
for i in range(1 , n+1):
if estDiviseur(i,n)==True:
b=b+1
if b>2:
return False
else:
return True
def nbPremiers(n):
c=0
for i in range(0,n):
if estPremier(i)==True:
c=c+1
return c
^\h*<img src=("[^"]+")>
<a target="_blank" href="$1">\n$0
<强>解释强>
. matches newline
<强>替换强>
^ : begining of line
\h* : 0 or more horizontal spaces (space or tabulation)
<img src= : literally <img src=
( : start group 1
"[^"]+" : 1 or more non quote character between quotes
) : end group 1
> : literally >
给定示例的结果:
<a target="_blank" href="$1"> : <a...> tag, with value in group 1 (ie. image filename)
\n : linebreak (you could use "\r\n")
$0 : content of group 0 (ie. the whole match: <img ...>)
答案 1 :(得分:0)
尝试使用find&amp;由Regex取代:
Find: <img src=\"(.*)\"> (you may add / at beginning and ending position if needed)
Replace: <a target="_blank" href="$1"> (add / at beginning or ending if needed)
希望它对你有所帮助。