码迷,mamicode.com
首页 > 其他好文 > 详细

How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops

时间:2021-04-14 12:44:22      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:flow   ring   tween   java   intern   put   visual   rip   blank   

How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops

Regular expressions are used for Pattern Matching.

To use in Excel follow these steps:

Step 1: Add VBA reference to "Microsoft VBScript Regular Expressions 5.5"

  • Select "Developer" tab (I don‘t have this tab what do I do?)
  • Select "Visual Basic" icon from ‘Code‘ ribbon section
  • In "Microsoft Visual Basic for Applications" window select "Tools" from the top menu.
  • Select "References"
  • Check the box next to "Microsoft VBScript Regular Expressions 5.5" to include in your workbook.
  • Click "OK"

Step 2: Define your pattern

Basic definitions:

 

 

VBScript’s Regular Expression Support

VBScript has built-in support for regular expressions. If you use VBScript to validate user input on a web page at the client side, using VBScript’s regular expression support will greatly reduce the amount of code you need to write.

Microsoft made some significant enhancements to VBScript’s regular expression support in version 5.5 of Internet Explorer. Version 5.5 implements quite a few essential regex features that were missing in previous versions of VBScript. Whenever this website mentions VBScript, the statements refer to VBScript’s version 5.5 regular expression support.

Basically, Internet Explorer 5.5 implements the JavaScript regular expression flavor. But IE 5.5 did not score very high on web standards. There are quite a few differences between its implementation of JavaScript regular expressions and the actual standard. Fortunately, most are corner cases that are not likely to affect you. Therefore, everything said about JavaScript’s regular expression flavor on this website also applies to VBScript. Modern versions of IE still use the IE 5.5 implementation when rendering web pages in quirks mode. In standards mode, modern versions of IE follow the JavaScript standard very closely. VBScript regular expressions also still use the IE 5.5 implementation, even when a modern version of IE is installed.

JavaScript and VBScript implement Perl-style regular expressions. However, they lack quite a number of advanced features available in Perl and other modern regular expression flavors:

 

How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops

标签:flow   ring   tween   java   intern   put   visual   rip   blank   

原文地址:https://www.cnblogs.com/chucklu/p/14656576.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!