Community Patterns

1

Paragraph Delimiter Counter (Unicode-Aware)

Created·2024-12-05 02:56
Updated·2024-12-05 03:24
Flavor·.NET 7.0 (C#)
Finds all paragraphs in the input text, where a paragraph is defined as any occurrence of a non-whitespace character immediately following any of the following and any other preceding whitespace: 2 or more consecutive CRLF sequences 2 or more consecutive CR characters 2 or more consecutive LF characters 1 or more Unicode Paragraph Separator class characters The beginning of the string (matches the first paragraph) Again, note that whitespace mixed in with the above will not interfere with the matching, as demonstrated by the test text included. This is intended to be used with the options specified, so be sure to include them for best performance (non-backtracking, multiline, non-capturing, invariant culture). This will work effectively on any version of .net that supports the included syntax. However, it is intended for use with .net8.0 and up, with the Regex.EnumerateMatches() method, or, more ideally, with .net9.0 and up, using the new Regex.EnumerateSplits() method, to avoid allocations associated with Match objects. Unicode paragraph separator characters are very rare in practice and support for them is almost non-existent in software, including the Windows Console. Windows Terminal, web browsers, the Windows clipboard, notepad, Visual Studio, and notepad++, all of which fail to handle it in their own ways, none of them actually adding a line when they occur (though notepad++ will show it as PS if you have enabled showing all whitespace). It is safe to remove |\p{Zp}+ from the pattern, if you do not wish to include those characters in your search. The resulting pattern, as a c# string, would be: "((\\r\\n|\\r|\\n){2,}|\\A)^\\s*\\S"
Submitted by dodexahedron
1

INI Parser

Created·2024-04-03 08:20
Updated·2024-08-28 12:56
Flavor·.NET 7.0 (C#)
This regular expression has the following features that make it a convenient tool for working with text data. (?=\S) Positive lookahead, trims leading whitespace in text block. (? ... ) Group for text block, which can be comment, section, entry, or undefined string. (? ... ) Group for comment. Includes # or ;, then spaces (if any), then comment value. (?[#;]+) Group for comment opening characters (# or ;). (?:*) Non-capturing group for spaces, excluding newlines. (?.+) Group for value following comment opening characters. (? ... ) Group for section. Includes opening bracket [, then spaces (if any), then section value, then closing bracket ]. (?\[) Group for opening bracket [. (?:\s*) Non-capturing group for spaces after the opening bracket [. (?]*\S+) Group for the section value, excluding the closing bracket ] and capturing the last non-space character. (?:*) Non-capturing group for spaces after the section value before the closing bracket ]. (?\]) Group for the closing bracket ]. (? ... ) Group for an entry (parameter and its value). Includes the key, the separator (: or =), and the value. (?]*\S) Group for the entry key, excluding the =, [, ] and newline characters, and capturing the last non-space character. (?:*) Non-capturing group for spaces after the key before the separator (: or =). (?: =) __(?*)__ Group for the entry value, excluding #, ; and newline. (?:*) Non-capturing group for whitespace after the entry value. (?.+) Group for an undefined string that does not match any other rules. (?\r\n|\n) Group for newline characters. (?+) Group for whitespace characters, excluding newline characters.
Submitted by Pavel Bashkardin

Community Library Entry

0

Regular Expression
Created·2021-09-11 09:45
Flavor·PCRE2 (PHP)

/
^.*?:\d\d.*?\n+|^\n+$|^.*?replies.*?\n+|^.*?\d\n+|^.*?:\n+|^Last reply.*?\n+
/
gm
Open regex in editor

Description

Before

I recommend XMind 8 and not the newer XMind Zen (I have not tried XMind 2021). It is available here: xmind.net/download/xmind8 (edited) 
:heavy_plus_sign:
1





5 replies
Last reply 24 hours agoView thread






Paul Holland  1:49 AM
If you need to convert to a PDF - you do not need to pay for the Pro version. On a Mac just print to a PDF. On a Windows machine use an app that lets you print to a PDF.
:point_up_2:
1


After

I recommend XMind 8 and not the newer XMind Zen (I have not tried XMind 2021). It is available here: xmind.net/download/xmind8 (edited) 
If you need to convert to a PDF - you do not need to pay for the Pro version. On a Mac just print to a PDF. On a Windows machine use an app that lets you print to a PDF.

Submitted by Maksim Zinovev