Use regular expressions to analyze the processes or functions contained in a piece of VB code.

Source: Internet
Author: User

Regular Expression:

^ (? : Public | private )? *? (Sub | function | property (? : Let | set | get) +? (/W + )/(?
 

 

VB processing method:

Option explicit <br/> private sub form_load () <br/> dim strdata $ <br/> dim Reg as object <br/> dim matchs as object, match as object </P> <p> strdata = "option explicit" & vbcrlf & _ <br/> "Public formdisplayed as Boolean" & vbcrlf & _ <br/> "Public vbinstance as vbide. VBE "& vbcrlf & _ <br/>" dim mcbmenucommandbar as office. commandbarcontrol "& vbcrlf & _ <br/>" Public withevents menuhandler as comma Ndbarevents 'COMMAND Bar event handler "& vbcrlf & _ <br/>" "& vbcrlf & _ <br/>" 'This event fires when the menu is clicked in the IDE "& vbcrlf & _ <br/> "private sub menuhandler_click (byval commandbarcontrol as object, handled as Boolean, canceldefault as Boolean) "& vbcrlf & _ <br/>" 'dim dd as object, CC as object, S $, I "& vbcrlf & _ <br/>" 'set dd = vbinstance. commandbars "& vbcrlf & _ <br/> "'" & Vbcrlf & _ <br/> "'s = vbinstance. commandbars. count & vbcrlf "& vbcrlf & _ <br/>" 'for I = 10 to vbinstance. commandbars. count-1 "& vbcrlf & _ <br/>" 'set cc = vbinstance. commandbars (I) "& vbcrlf & _ <br/>"'s = S & CC. index & vbtab & CC. name & vbtab & CC. namelocal & vbcrlf "& vbcrlf & _ <br/>" 'Next "& vbcrlf & _ <br/>" "& vbcrlf & _ <br/>" 'vbinstance. activecodepane. codemodule. inser Tlines 5, "" fadsfsadfsdafsdaf "" & vbcrlf & _ <br/> "msgbox vbinstance. activecodepane. codemodule. countoflines "<br/> set Reg = Createobject (" VBScript. regexp ") <br/> Reg. global = true <br/> Reg. ignorecase = true <br/> Reg. pattern = "(?: Public | private )? *? (?: Sub | function) +? (/W + )/(? "</P> <p> set matchs = reg. execute (strdata) </P> <p> for each match in matchs <br/> debug. print match. submatches (0) <br/> next <br/> end sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.