问题
We all know that every regex implementation has its own peculiarities. I need to us the Microsoft VBVScript RegExp object in an app using COM Automation, but I could not find a good documentation for it except this overview:
Microsoft Beefs Up VBScript with Regular Expressions
http://msdn.microsoft.com/en-us/library/ms974570.aspx
MSDN also contains this section for regular expressions, but it is for JavaScript:
Introduction to Regular Expressions (JavaScript)
http://msdn.microsoft.com/en-us/library/6wzad2b2.aspx
Can we use all the features described in this section for VBScript RegExp object?
回答1:
According to regular-expressions.info most of the regular expression stuff in Javascript applies to VBScript. They have also a quite complete description of the exceptions and limitations of VBScript regexes.
There is also a neat trick you can do with the .Replace
method: adding a function reference to manipulate the replace return value.
回答2:
Answering your "Is there a good documentation for VBScript Regular Expression object (RegExp)?" and not your second question.
This is the best I have found and you might find it good enough:
"Regular Expression (RegExp) Object"
https://msdn.microsoft.com/library/yab2dx62.aspx
"Introduction to Regular Expressions (Scripting)"
https://msdn.microsoft.com/library/6wzad2b2.aspx
"Introduction", note, rather than reference.
Though this Introduction is not part of the VBScript docs, I hope its
"However, regular expressions may also be more efficient to use in VBScript as well"
https://msdn.microsoft.com/library/5t8zc0b0.aspx
can be safely taken to mean it applies to VBScript.
HOWEVER BE WARNED that these are incomplete, as I recently discovered thanks to a nasty bug triggered by a plain input replacement string containing the sequence $&, which is reserved yet not documented as such in either of the above, including in the place that documents other replacement reserved sequences https://msdn.microsoft.com/library/k9z80300.aspx .
来源:https://stackoverflow.com/questions/21573093/is-there-a-good-documentation-for-vbscript-regular-expression-object-regexp