RegExMatchCs and RegExReplaceCs

Matches or replaces text using .NET regular-expression syntax instead of PCRE2.

These functions are exported by the KS module.

FoundPos := RegExMatchCs(Haystack, NeedleRegEx , &OutputVar, StartingPos := 1)
NewStr := RegExReplaceCs(Haystack, NeedleRegEx , Replacement := "", &OutputVarCount, Limit := -1, StartingPos := 1)

The general parameter and return conventions match RegExMatch and RegExReplace. RegExMatchCs writes a RegExMatchInfo object. An invalid pattern throws an Error whose Extra is the .NET error message.

A StartingPos below 1 selects a right-to-left search. With 0, the search currently starts at index 0 rather than the end of the string; this limits the matches it can find.

Replacement is converted to a string; a function replacement is not supported.

Pattern and Option Differences

Further Reading

See Microsoft's .NET regular expressions guide.