Here are a couple of wrapper VBScript functions that make using script’s built-in
RegExp class similar to PHP’s
preg_xxx family of functions.
First a private helper function to initialize an instance of
This enables optionally to set flags of the object in the search string after the trailing slash e.g. “/test/mi” will search for “test” ignoring case and multi-line. This helper function is not meant to be used by the client scripts but helps implement the actual search&replace functions.
Next the implementation of
preg_split becomes very simple
These are fairly straight forward and are about enough to complete 99% of any search&replace task at hand. For
preg_replace one can use replace placeholders in VBScript notation ($1, $2, etc.) to match search groups.
The troublesome 1% with this implementation of
preg_replace is that it cannot handle callback functions for
replace_arg. So here is a…
View original post 214 more words