Table of Contents

Class RegexUtility

Namespace
Songhay
Assembly
SonghayCore.dll

Shared routines for Regex

public static class RegexUtility
Inheritance
RegexUtility
Inherited Members

Methods

GetInnerXmlPattern(string?)

Regex pattern getter

public static string GetInnerXmlPattern(string? elementName)

Parameters

elementName string

Returns

string

GetLinesStartingWithWhitespaceCharactersPattern(string, byte)

Regex pattern getter

public static string GetLinesStartingWithWhitespaceCharactersPattern(string newLine = "\r\n", byte numberOfChars = 4)

Parameters

newLine string

the conventional NewLine characters of the lines

numberOfChars byte

the number of white space characters to remove

Returns

string

MatchAllCharactersInQuotes()

[GeneratedRegex("([\"'])(?:(?=(\\\\?))\\2.)*?\\1")]
public static Regex MatchAllCharactersInQuotes()

Returns

Regex

Remarks

Pattern:

(["'])(?:(?=(\\\\?))\\2.)*?\\1

Explanation:<br />
<pre><code class="lang-csharp">○ 1st capture group.
○ Match a character in the set ["'].

○ Loop lazily any number of times. ○ Zero-width positive lookahead. ○ 2nd capture group. ○ Match '\' atomically, optionally. ○ Match the same text as matched by the 2nd capture group. ○ Match any character other than '\n'. ○ Match the same text as matched by the 1st capture group.

MatchAllCharactersIndicatingParentDirectory()

[GeneratedRegex("\\.\\./|\\.\\.\\\\")]
public static Regex MatchAllCharactersIndicatingParentDirectory()

Returns

Regex

Remarks

Pattern:

\\.\\./|\\.\\.\\\\

Explanation:<br />
<pre><code class="lang-csharp">○ Match the string "..".

○ Match a character in the set [/\].

MatchAllCharactersNotAlphanumeric()

[GeneratedRegex("[^a-z^0-9]", RegexOptions.IgnoreCase)]
public static Regex MatchAllCharactersNotAlphanumeric()

Returns

Regex

Remarks

Pattern:

[^a-z^0-9]

Options:<br />
<pre><code class="lang-csharp">RegexOptions.IgnoreCase</code></pre><br />
Explanation:<br />
<pre><code class="lang-csharp">○ Match a character in the set [^0-9A-Z^a-z\u212A].</code></pre>

MatchAllCharactersNotNumeric()

[GeneratedRegex("\\D")]
public static Regex MatchAllCharactersNotNumeric()

Returns

Regex

Remarks

Pattern:

\\D

Explanation:<br />
<pre><code class="lang-csharp">○ Match any character other than a Unicode digit.</code></pre>

MatchAllSpaceCharactersRepeatedTwoOrMoreTimes()

[GeneratedRegex(" {2,}")]
public static Regex MatchAllSpaceCharactersRepeatedTwoOrMoreTimes()

Returns

Regex

Remarks

Pattern:

{2,}

Explanation:<br />
<pre><code class="lang-csharp">○ Match ' ' atomically at least twice.</code></pre>

MatchAllThatLooksLikeEmailAddress()

[GeneratedRegex("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")]
public static Regex MatchAllThatLooksLikeEmailAddress()

Returns

Regex

Remarks

Pattern:

\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*

Explanation:<br />
<pre><code class="lang-csharp">○ Match a word character greedily at least once.

○ Loop greedily any number of times. ○ 1st capture group. ○ Match a character in the set ['+-.]. ○ Match a word character atomically at least once. ○ Match '@'. ○ Match a word character greedily at least once. ○ Loop greedily any number of times. ○ 2nd capture group. ○ Match a character in the set [-.]. ○ Match a word character atomically at least once. ○ Match '.'. ○ Match a word character greedily at least once. ○ Loop atomically any number of times. ○ 3rd capture group. ○ Match a character in the set [-.]. ○ Match a word character atomically at least once.

MatchAllThatLooksLikeUnc()

[GeneratedRegex("^(\\\\(\\\\[^\\s\\\\]+)+|([A-Za-z]:(\\\\)?|[A-z]:(\\\\[^\\s\\\\]+)+))(\\\\)?$")]
public static Regex MatchAllThatLooksLikeUnc()

Returns

Regex

Remarks

Pattern:

^(\\\\(\\\\[^\\s\\\\]+)+|([A-Za-z]:(\\\\)?|[A-z]:(\\\\[^\\s\\\\]+)+))(\\\\)?$

Explanation:<br />
<pre><code class="lang-csharp">○ Match if at the beginning of the string.

○ 1st capture group. ○ Match with 2 alternative expressions. ○ Match a sequence of expressions. ○ Match '\'. ○ Loop greedily at least once. ○ 2nd capture group. ○ Match '\'. ○ Match a character in the set [^\\s] greedily at least once. ○ 3rd capture group. ○ Match with 2 alternative expressions. ○ Match a sequence of expressions. ○ Match an ASCII letter. ○ Match ':'. ○ Optional (greedy). ○ 4th capture group. ○ Match '\'. ○ Match a sequence of expressions. ○ Match a character in the set [A-z]. ○ Match ':'. ○ Loop greedily at least once. ○ 5th capture group. ○ Match '\'. ○ Match a character in the set [^\\s] greedily at least once. ○ Optional (greedy). ○ 6th capture group. ○ Match '\'. ○ Match if at the end of the string or if before an ending newline.

MatchAllWords()

[GeneratedRegex("\\w+")]
public static Regex MatchAllWords()

Returns

Regex

Remarks

Pattern:

\\w+

Explanation:<br />
<pre><code class="lang-csharp">○ Match a word character atomically at least once.</code></pre>

MatchCommandLineArgumentInQuotesFollowedByOtherArguments()

[GeneratedRegex("\"[^\"]+\"|\\s+.+")]
public static Regex MatchCommandLineArgumentInQuotesFollowedByOtherArguments()

Returns

Regex

Remarks

Pattern:

"[^"]+"|\\s+.+

Explanation:<br />
<pre><code class="lang-csharp">○ Match with 2 alternative expressions, atomically.
○ Match a sequence of expressions.
    ○ Match '"'.
    ○ Match a character other than '"' atomically at least once.
    ○ Match '"'.
○ Match a sequence of expressions.
    ○ Match a whitespace character greedily at least once.
    ○ Match a character other than '\n' atomically at least once.</code></pre>