文本编辑器:如何将第二行复制到其他代码

时间:2017-10-04 14:38:28

标签: html notepad++ text-editor



<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;
&#13;
&#13;

我需要复制行并更改 img src为其他行的target="_blank" href并保持img src值相同。

有办法吗?

2 个答案:

答案 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)

希望它对你有所帮助。