web-dev-qa-db-ja.com

正規表現OR notepad ++で

Notepad ++で次のすべてのインスタンスを見つけたい

_action421
action732
action983
_

ただし、他のすべてのactionXXXの組み合わせは無視してください。

action(421)|(732)|(983)に似た正規表現を探していますが、機能しません。どんな正規表現でしょうか?

notepad ++ regex engine にはOR演算子さえありますか?

30
Jonathan

Don HoはRegEx OR |演算子をNotepad ++ネイティブFindに追加したようです
メモ帳の最新バージョン(ver。6.1.1)。
メモ帳6.1.1を こちら からダウンロードします

メモ帳6.1.1をインストールし、[検索]-> [検索]に移動します。
検索対象:action(421|732|983)
検索モード:(*) Regular Expression

クリックしてください Find Nextボタン

35
user78706

メモ帳で可能になりました> = 10.1.1。Dragos Toader : "今日の最新バージョン( Notepad 10.1.1)がサポート| RegExで "

==以下の元の回答==

Notepad ++では不可能です。 この回答を参照してください。

しかし、正規表現は正しくありません。これは動作します:action(421|732|983) Notepad ++が|正規表現。

8
Rudie

Notepad ++には regex helper plugin を使用できますが、それは置換よりも正規表現の開発に向いていますが、見つけたいだけであれば、このプラグインが役立つと思います。

enter image description here

6
manojlds

PythonScript Notepad ++プラグインを使用してPython正規表現検索機能。
関数については、 こちら を参照

_Editor.pysearch(expression, function[, flags[, startLine[, endLine]]])
_

または

_Editor.pymlsearch(expression, function[, flags[, startPosition[, endPosition]]])  
_

python正規表現検索関数editor.pysearch()を使用した簡単なプログラムです。
関数の実行中に何が起こっているかを確認できるように、多くのデバッグコードを残しました。

_# $Revision: 1.3 $
# $Author: dot $
# $Date: 2012/04/19 00:03:26 $

from Npp import *
import re, string

expression = notepad.Prompt(
                 "Enter the RegEx search string then press Enter",
                 "RegEx and Search" ,
                 "")

debug = True
#debug = False

if debug:
    bufferID = notepad.getCurrentBufferID()

if debug:
    # Show console for debugging
    console.clear()
    console.show()

if expression != None:
    expressionSansNl = expression.replace('\r\n', '')

    if debug:
        console.write( expression + "\n" )

    # First we'll start an undo action, then Ctrl-Z will undo the actions of the whole script
    editor.beginUndoAction()

    if debug:
        console.write( 'editor.pysearch( r"%s" % expressionSansNl, None)\n' )

    editor.pysearch( r"%s" % expressionSansNl, None)

    # End the undo action, so Ctrl-Z will undo the above two actions
    editor.endUndoAction()

# Debug
if debug:
    notepad.activateBufferID(bufferID)
_

このスクリプトをNotepad ++ショートカット_Ctrl+<ChooseALetter>_にマッピングして実行します。
検索正規表現を入力action(421|732|983)
Python re documentation here )によれば、_|_ RegEx演算子がサポートされています。

私はこれをテストしていません-おそらくpysearch()関数のNoneパラメーターが必要です
結果の文字列を選択する関数になります。ドキュメント here によると、
関数はpython MatchObjectを返す必要があります。
MatchObjectからの一致文字列と、その一致の次の外観を選択
エディターオブジェクトの文字列。コーディングが完了したら、回答の新しい改訂版を投稿します
そしてこれをテストします。

1
user78706

Notepad ++ サポートしません 代替operator|。あなたはtextfxを試すことができます ctrl+R regexpオプションですが、同じことが当てはまると思います。

1
Alex K.

あなたの正規表現は正しいようです。しかし、これを使用してみてください:

action(421|732|983)
0
Headshota