Is there a good documentation for VBScript Regular Expression object (RegExp)? [closed]

天涯浪子 提交于 2019-12-11 04:08:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!