Skip to content

Commit

Permalink
Update FunctionList regex and main regex sections
Browse files Browse the repository at this point in the history
- make it more clear on FuncList page that Notepad++ uses Boost, and again direct reader to the other page for more details
- make it clear that regex-explainer sites may be using a different syntax than Notepad++

<see discussion around https://community.notepad-plus-plus.org/post/93141>
  • Loading branch information
pryrt committed Feb 24, 2024
1 parent 6642d87 commit dfbd0c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions content/docs/function-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ There are 3 kinds of parsers: function parser, class parser, and mixed parser.

_Notes on regular expressions for parsers_:

Other than the caveats below, the function list regular expressions follow the same syntax spelled out in the docs on [Searching: Regular Expressions](../searching/#regular-expressions):
The function list regular expressions follow the same syntax spelled out in the docs on [Searching: Regular Expressions](../searching/#regular-expressions), with the following exceptions or clarifications:

- The parser does not accept **regular expression look behind operations** in the expressions.
- The parser can only search for function names, it will not do **regular expression replacement or modification** (so you cannot add text to the matching names)
- The parser can only search for function names, it will not do **regular expression replacement or modification** (so you cannot add text to the matching names, or remove text from the middle; to remove text from the beginning or the end, use `\K` to reset the match, or use **look ahead operations**)
- You _may_ use the `(?x)` modifier to allow additional whitespace and `#`-prefixed comments in your regular expression, as described in the docs on [regex search modifiers](../searching/#search-modifiers)
- The parser defaults to `. matches newline` being turned on (the equivalent of `(?s)` inside a regex). If you want `.` to _not_ match newlines, please include `(?-s)` in your FunctionList definition regular expressions.

Because the Function List parser uses a subset of the same regular expression syntax that Notepad++ uses for **Search > Find** regular expressions, you can use Notepad++'s search dialog with **Search Mode** set to **☑ Regular Expression** to experiment with the searches. (If you choose to use some other tool -- like one of the many web-based regex explainers -- to help you debug your expression for your Function List definition, please understand that there are many implementations of regular expressions, and even very similar implementations have subtle differences in behavior. You would need to find a tool that uses the exact same Boost library version that Notepad++ uses to have their results be identical. The [Searching: Regular Expressions](../searching/#regular-expressions) section should always list the version of the Boost library used by the most recent Notepad++.)

### Function parser
The `<function>` node accepts the following attributes and contained elements:

Expand Down
2 changes: 1 addition & 1 deletion content/docs/searching.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ In extended mode, these escape sequences (a backslash followed by a single chara

## Regular Expressions

Notepad++ regular expressions ("regex") use the Boost regular expression library v1.80 (as of NPP v8.4.7), which is based on PCRE (Perl Compatible Regular Expression) syntax, only departing from it in very minor ways. Complete documentation on the precise implementation is to be found on the Boost pages for [search syntax](https://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html) and [replacement syntax](https://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html)
Notepad++ regular expressions ("regex") use the Boost regular expression library v1.80 (as of NPP v8.4.7), which was originally based on PCRE (Perl Compatible Regular Expression) syntax, only departing from it in very minor ways. Complete documentation on the precise implementation is to be found on the Boost pages for [search syntax](https://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html) and [replacement syntax](https://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html). (Some users have misunderstood this paragraph to mean that they can use one of the regex-explainer websites that accepts PCRE and expect anything that works there to also work in Notepad++; this is not accurate. There are many different "PCRE" implimentations, and Boost itself does not claim to be "PCRE", though both Boost and PCRE variants have the same origins in an early version of Perl's regex engine. If your regex-explainer does not claim to use the same Boost engine as Notepad++ uses, there _will_ be differences between the results from your chosen website and the results that Notepad++ gives.)

The Notepad++ Community has a [FAQ on other resources for regular expressions](https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation).

Expand Down

0 comments on commit dfbd0c2

Please sign in to comment.