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 RegExMatchInfoCs object, which provides the same match-information interface using .NET groups. Invalid patterns throw .NET regular-expression exceptions rather than PCRE exceptions.

That interface includes every member of a PCRE match object, among them Success, which is 1 when the pattern matched and 0 otherwise, and ToString(), which returns the position of the overall match.

Pattern and Option Differences

Further Reading

See Microsoft's .NET regular expressions guide.