Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
Dragoș Valentin, Rădulescu
Hello, i was wondering if there is a way to search in an array and replace the searched words with something else.
WORD1 || WORD2 || WORD3
WORD4 || WORD5 || WORD6
Is it possible?
If not, could you include such a feature? :)
The shor answer is no.
A longer answer is that Scintilla does not support aternation in regular expressions. This issue will go the day N++ uses a different search engine - pcre being the one that makes the moore sense.
From the 6.0 version of Notepad++, SEVERAL searched words can
be CHANGED in SEVERAL replacement words, at the SAME TIME !
We must use a special syntax, in the replacement part :
FIND : (WORD1)|(WORD2)|(WORD3)…
REPLACE : (?1WORD4)(?2WORD5)(?3WORD6)…
Some explanations :
The words WORD1, WORD2 and WORD3 are stored as GROUPS 1, 2 and 3
If we find WORD1, it's replaced by WORD4, the part AFTER ?1 and BEFORE the ENDING parenthesis
If we find WORD2, it's replaced by WORD5, the part AFTER ?2 and BEFORE the ENDING parenthesis
If we find WORD3, it's replaced by WORD6, the part AFTER ?3 and BEFORE the ENDING parenthesis
For example, the line : WORD3 WORD2 WORD1 WORD3 WORD1 WORD2
would be changed in : WORD6 WORD5 WORD4 WORD6 WORD4 WORD5
The general form of a CONDITIONNAL REPLACEMENT is :
(?n___THEN part___:___ELSE part___) and means :
- if GROUP n EXISTS, EVERYTHING BETWEEN ?n and the COLON : is written, in replacement
- if GROUP n DON'T EXIST, EVERYTHING BETWEEN the COLON : and the ENDING parenthesis is written, in replacement
You can find some documentation, about the new PRCE Regular Expressions, used by N++ at the
two adresses below :
Also, I've made a TUTORIAL, about the PCRE Regular Expressions ( Perl Common Regular Expressions ),
used in Notepad++, from the 6.0 version.
As I'm French, all this manual is written in French. but you can find out some tricks or explanations
in all the lists and examples, all along this tutorial.
Christian Cuvier ( cchris ), a very well-known contributer, allowed me to put my tutorial on his personnel site.
So, you can download this TUTORIAL, in 3 versions, (.txt .pdf .html), at the address below :
I hope it'll be useful to you