उपयोग PythonScript Notepad ++ पायथन नियमित अभिव्यक्ति खोज कार्य के लिए प्लगइन।
कार्यों
Editor.pysearch(expression, function[, flags[, startLine[, endLine]]])
या
Editor.pymlsearch(expression, function[, flags[, startPosition[, endPosition]]])
यहाँ एक सरल अजगर नियमित अभिव्यक्ति खोज समारोह editor.pysearch()
मैं तो तुम में डिबग कोड के बहुत सारे छोड़ दिया है का उपयोग कर कार्यक्रम है के लिए here देखें देख सकते हैं कि फ़ंक्शन रन के दौरान क्या हो रहा है।
# $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)
मानचित्र नोटपैड को यह स्क्रिप्ट ++ शॉर्टकट Ctrl+<ChooseALetter>
और इसे चलाने के।
खोज में टाइप करें RegEx action(421|732|983)
पायथन पुन: प्रलेखन here के अनुसार, |
RegEx ऑपरेटर समर्थित है।
मैंने इसका परीक्षण नहीं किया है - शायद pysearch() फ़ंक्शन में कोई भी पैरामीटर
फ़ंक्शन होने के लिए परिणामस्वरूप स्ट्रिंग का चयन करेगा।दस्तावेज़ों के अनुसार here,
फ़ंक्शन को एक अजगर MatchObject वापस करना चाहिए। मुझे लगता है कि MatchObject से
मिलान स्ट्रिंग प्राप्त करने का एक तरीका है और संपादक ऑब्जेक्ट में
स्ट्रिंग के उस मिलान की अगली उपस्थिति का चयन करें। एक बार जब मैं
कोडिंग कर रहा हूं और इसका परीक्षण कर रहा हूं तो मैं जवाब का एक नया संशोधन पोस्ट करूंगा।
स्रोत
2012-04-20 17:05:21
संस्करण 10.1.1 के रूप में नोटपैड ++ रेगेक्स इंजन में एक OR ऑपरेटर है। –