-1

ランダムなコードを含むスクリプトがありますが、メモ帳 ++ で方法を探しているか、バッチファイルまたは sepcifque コードを置き換えることができるツールを探しています。例を次に示します。

Random
If this equal that then you soulAd do this and do that therefore..
the code should be executed immediatly
--stackb

select * from user_error where object_name = name
select * from user_error where table= randomly

case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know

コメントスタックbとスタックaの間の単語を置き換えたいので、結果は以下のようになります

Random
If this equal that then you sould do this and do that therefore..
the code should be executed immediatly
--stackb

The codes here has been replaced,
can you do that ?

case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know

結果を達成できるバッチファイルまたはメモ帳++にコードはありますか?

4

1 に答える 1

2

Notepad++ で、Search > Replaceメニュー (ショートカットCTRL+ H) に移動し、次の操作を行います。

  1. 何を見つけるか (説明は以下を参照):

    (\-\-stackb.*?)select.+?$\r?\nselect.+?$(\r?\n.*?\-\-stacke)
    
  2. 交換:

    $1replaced text$2
    
  3. ラジオボタン「正規表現」を選択し、チェックボックス「.matches newline」を選択します

  4. を押しReplace Allます。

これにより、次のファイルが変換されます。

Random
If this equal that then you soulAd do this and do that therefore..
the code should be executed immediatly
--stackb

select * from user_error where object_name = name
select * from user_error where table= randomly

case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know

に:

Random
If this equal that then you soulAd do this and do that therefore..
the code should be executed immediatly
--stackb

replaced text

case 1 a = b else c=a
--stacke
Begin with the structure of the data and divide the codes
end with what you know

正規表現の説明:

  • \-\-stackb文字列 に一致します--stackb特殊文字をエスケープするバックスラッシュを除いて、ここでは特別なことは何もありません。これは、正規表現の特殊文字としてではなく-、リテラルとして解釈されることを意味します-
  • .*?オプション「.matches newline」を有効にしたため、ドットは任意の文字と改行に一致します.。アスタリスクは、0 回以上の一致を表す量指定子です。したがって、任意の文字または改行に 0 回以上一致することを意味します。量指定子の後にクエスチョンマークが続くと、量指定子が非貪欲になります。これはより高度なトピックですが、簡単に言えば、量指定子に可能な最小量で自分を満足させようと言っているようなものです。*.*?.
  • (\-\-stackb.*?)正規表現の意味を理解したので、一致する結果を取得するために括弧を追加できます。特殊変数を使用して結果にアクセスできます$1(または\1同じです)。ご覧のとおり交換で使用しております。
  • select.+?$\r?\nここでの唯一の新しいものは、改行を見つけるために使用される行末と特殊文字(改行)、(改行) に一致する です$1 回または 0 回の一致を意味する数量子が後に続くことに注意してください。\r\n\r?
于 2013-10-29T10:09:53.320 に答える