FAQ: Where to find REGular EXpressions (RegEx) documentation ?
-
Hello and welcome to the FAQ Desk. You have likely been directed here because you asked about N++ regex flavor, [ N++ ] regex documentation or N++ regex enhancements.
Preliminary Note : As recalled recently by @peterjones, our forum is not a professional regex-writing forum. We are users of Notepad++, who want to help others learn more about NPP (and learn more ourselves, in the process). Since Notepad++ makes use of regular expressions, we will often provide help with regex questions
Our present regex engine is implemented since Ascii and Unicode version
6.0
of Notepad++ and improved till thev6.4.2
version, by, both, Dave BrotherStone and François-R Boyer. Previously, It used the Regex library, of the Boost C++ librariesv1.55.0
, similar to the PERL Regular Common Expressionsv5.8
Starting with Notepad++
v7.7
, it currently used the Boost C++ regex libraryv1.70.0
. Since this release, the Backtracking Control Verbs are supported. Refer to the link, below, for information on this new feature :https://community.notepad-plus-plus.org/post/55464
Since Notepad++
v8.2
, the current Boost C++ regex library is the releasev1.78.0
Notepad++
v8.4.7
switched to Boost C++ regex libraryv1.80.0
For noob people, about regular expressions concept and syntax, begin with that article, elaborated by Peter Jones and part of the Notepad++ Documentation :
https://npp-user-manual.org/docs/searching/#regular-expressions
Note that the old link of the outdated Notepad++ Wiki ( http://docs.notepad-plus-plus.org/index.php/Regular_Expressions ) as well as the temporary link, on GitHub ( http://notepad-plus-plus.github.io/npp-usermanual/content/searching/ ) are, from now on, obsolete
In addition, whatever its level, anyone will find good documentation, about the regex library; of the Boost C++ libraries
v1.80.0
, from the two addresses below :http://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
http://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
-
The FIRST link explains the syntax, of regular expressions, in the SEARCH part.
-
The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part.
And, possibly, take a glance at the Standards Conformance :
https://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/background/standards.html
You may, also, look for valuable information, on this non-exhaustive list of sites, below :
General Information
:
https://en.wikipedia.org/wiki/Regular_expression
Summary of Regex Syntax
( Cheat Sheet and Basic Features ) :
https://www.regular-expressions.info/quickstart.html
http://www.rexegg.com/regex-quickstart.html
https://regex101.com/ — Quick Reference panel ( Thanks to Jim Dailey )
https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285
https://ryanstutorials.net/regular-expressions-tutorial/ — Excellent introduction
https://www.geeksforgeeks.org/write-regular-expressions/
https://docs.python.org/2/howto/regex.html
https://www.debuggex.com/cheatsheet/regex/pcre
http://regexstorm.net/reference
Full Documentation and Advanced Information
:
http://www.regular-expressions.info ( the REFERENCE ! )
https://gammon.com.au/pcre/pcrepattern.html
http://perldoc.perl.org/perlre.html
https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean
Regex Testers
:
https://www.regexbuddy.com — All flavors ( the REFERENCE ! )
https://regex101.com/ — PCRE , Python, JavaScript and Golang flavors
https://regexone.com/ — PCRE flavor
https://www.debuggex.com/ — JavaScript, Python and PCRE flavors ( Visual regex representation )
https://www.regextester.com/ — JavaScript and PCRE flavors
https://www.regexpal.com/ — JavaScript and PCRE flavors
https://www.freeformatter.com/regex-tester.html — JavaScript flavor
https://regexr.com/ — .NET flavor
Be aware that, as any documentation, it may contain some errors ! Anyway, if you’ve detected one, that’s good news : you’re improving ;-))
I highly recommend reading the contents of the third edition of the book Mastering Regular Expressions ( Understand your Data and Be More Productive ) by Jeffrey E. F. Friedl ( August 2006 ). If you find it of interest, just download this PDF file, of
534
pages.Refer for an English version ( ISBN
0-596-52812-4
) from the link, below :
Quotations :
Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now, they have two problems! — Jamie Zawinski
And, of course, one claimed precedence. One said: “I needed love, I got married. Then, I had two problems”! — Anonymous
REMARK :
After good practice, you will probably find out some unexpected results with our present N++ regex engine. In that case, you may try an old unofficial version, of the N++ regex engine, which corrects some bugs and adds some regex improvements :
-
Search and replacement are performed in true 32 bits code-points ( instead of UTF-16 )
-
So, it can handle ALL the Universal Character Names ( UCN) of the UCS Transformation Format , from
\x{0}
to\x{7FFFFFFF}
, particularly, all those of code-points over\x{FFFF}
, which are outside the BMP ( Basic Multilingual Plane ) -
Both, search and replace strings can contain embedded NUL characters and/or Escape sequences for NUL characters (
\x{0000}
) -
Backward assertions, as
\A
, are correctly supported ( OK with N++ sincev7.9.1
) -
Backward regex search does not stop, anymore, when matching a character with Unicode code-point over
\x{00FF}
-
Look-behinds are correctly handled, when searching or replacing, even those overlapping with the end of the previous match ( OK with N++ since
v7.9.1
) -
A new
[[:inval:]]
character class, which allows you to find invalid UTF-8 sequences, which can be kept in replacement
IMPORTANT : Unfortunately, this beta version, created in May 2013, by François-R Boyer can not be run with N++ versions higher than
v6.9.0
. So, if you need that improved regex engine, for specific cases, use the following method, which can be processed, independently of the present N++ version(s), in your configuration :- Download an archive of Notepad++
v6.9.0
,32 Bits
, from one of the links, below :
http://download.notepad-plus-plus.org/repository/6.x/6.9/npp.6.9.bin.7z
http://download.notepad-plus-plus.org/repository/6.x/6.9/npp.6.9.bin.zip
-
Extract all the contents of this archive, in a new directory
-
Rename the present
SciLexer.dll
file, as, for instance,SciLexer.OK
-
Download the François-R Boyer version of that dll, from :
https://sourceforge.net/projects/npppythonplugsq/files/Beta N%2B%2B regex code/SciLexer.dll/download
-
Place this new
SciLexer.dll
file, in this new N++ directory -
Start Notepad++
v6.9.0
-
And…, enjoy any complicated regex search/replacement !
NOTE : You may, also, have a look to his readme.txt file from :
http://sourceforge.net/projects/npppythonplugsq/files/Beta N%2B%2B regex code/
-
-
Additional Regex Tester tool (offline): RegEx Tester
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-