2016-12-09 1 views
1

notepad ++とregexにはかなり新しいし、私の仕事の大半はやっているが、今は止まっている。xmlファイル内のテキストを同じドキュメント内のソースエリアから置き換えるにはどうすればよいですか?

私はテキストを置き換える必要があるxmlファイルがたくさんありますが、置換テキストもxmlファイル内にあります。

誰でもこの方法を知っていますか?

を参照してください添付ファイルのスクリーンショットが、コードは以下の通りです:

<button name="Button2" height="39" width="124" left="211" top="422" visible="true" wallpaper="false" toolTipText="" exposeToVba="notExposed" isReferenceObject="false" style="3d" captureCursor="false" highlightOnFocus="true" tabIndex="1"> 
     <command pressAction="" repeatAction="" releaseAction="abz" repeatRate="0.25"/><button 
name="Button4" height="39" width="124" left="211" top="422" visible="true" wallpaper="false" toolTipText="" exposeToVba="notExposed" isReferenceObject="false" style="3d" captureCursor="false" highlightOnFocus="true" tabIndex="1"> 
<command pressAction="" repeatAction="" releaseAction=" abz" repeatRate="0.25"/> 

Private Sub Button2_Released() 
ScreenName = "test screen" 
Private Sub Button4_Released() 
ScreenName = "test screen info" 
[enter image description here][1] 

参照スクリーンショット、私は緑を交換しようとしている検索を経由して変数名からの情報で、ボタン式のテキストを強調表示し、交換してください青と赤のテキストは、マッチングパラメータと緑のある機能は、交換の場所で、黄色の交換用ソース

enter image description here

答えて

0

わからないbetwee任意のスペースがあるだろう場合でありますあなたのボタンとコマンドノードは、このようなものです。

検索:

<button name="([^"]+)" height="39" width="124" left="211" top="422" visible="true" wallpaper="false" toolTipText="" exposeToVba="notExposed" isReferenceObject="false" style="3d" captureCursor="false" highlightOnFocus="true" tabIndex="1"><command pressAction="" repeatAction="" releaseAction="[^"]*" 

は交換してください:

<button name="$1" height="39" width="124" left="211" top="422" visible="true" wallpaper="false" toolTipText="" exposeToVba="notExposed" isReferenceObject="false" style="3d" captureCursor="false" highlightOnFocus="true" tabIndex="1"><command pressAction="" repeatAction="" releaseAction="$1" 

それは最初のキャプチャグループ$ 1 releaseaction値に置き換えられます。 (ボタン名値)

0

あなた検索し、繰り返しこのパターンを置き換えることができます:

検索:(<button name=")(.*?)(".*?releaseAction=").*?"(.*?Private Sub)\2(_Released.*?ScreenName = ")(.*?)(?=")

置き換え:$1$2$3$6$4$2$5$6確認. matches newline

しかし、私は本当にそれをお勧めしません。

説明:括弧内

部分は「キャプチャグループ」と呼ばれ、検索ならびに置き換え式の中で参照することができます。

(<button name=")    group1  matches the part before the button name 
(.*?)      group2  matches the button name 
(".*?releaseAction=")  group3  matches the part between the button name 
             and the part to be replaced 
.*?          matches the part that will be replaced 
(".*?Private Sub)   group4  matches the rest of the xml up to the next occurence 
             of the button name 
\2          reference to group 2 (the button name) 
(_Released.*?ScreenName = ") group5  matches the part up to the screen name 
(.*?)      group6  matches the screen name      
(?=")      non capturing look ahead, makes sure the capture group 
関連する問題