Click here to Skip to main content
Licence CPOL
First Posted 29 Feb 2004
Views 33,472
Bookmarked 19 times

Convenient wrapper of VBScript.RegExp for VC++

By | 29 Feb 2004 | Article
Regular Expression for VC++ using VBScript.RegExp

Introduction

This is a wrapper of "VBScript.RegExp" or an example of how to use "RegExp" in VC++. I have implemented some often used methods. You can add any more as you need.

The VBScript.RegExp's performance is better than JScript.RegExp, but VBScript.RegExp did not provide 'lastIndex' property, so I selected VBScript.RegExp in VC++ and implemented 'lastIndex' by myself. I supply a convenient class RegExp, and the style is like JScript.RegExp.

When you use the regexp.h and regexp.cpp, do not forget to call CoInitializeEx or CoInitialize at the beginning of your program. Any suggestion is welcome. After you finish optimizing the code, please send a copy to me.

 CoInitializeEx( NULL, COINIT_MULTITHREADED );

 RegExp re;
 re.IgnoreCase( TRUE );

 re.compile( _T("\w([\d.]*)(\w+)") );
 re.exec( _T("I f3454ind it, f567.56ind it again") );

 cout << re.index << _T(" ~ ") << re.lastIndex << endl;
 cout << (LPCTSTR)re.SubMatch( 0 ) << endl;
 cout << (LPCTSTR)re.SubMatch( 1 ) << endl << endl;

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

sswater shi

Software Developer (Senior)

China China

Member

Begin coding from basic, since 1994. Interested in coding and database and website constructing.
My website: http://www.regexlab.com/ - Regular Expression Laboratory
The easiest regex engine: http://www.regexlab.com/deelx/

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionCan I use the object from STA? PinmemberAndreBroz4:50 3 Apr '12  
AnswerRe: Can I use the object from STA? Pinmembersswater shi16:45 3 Apr '12  
GeneralWorks Well Pinmembertimbolicus_prime7:15 7 Aug '08  
GeneralRe: Works Well Pinmembersswater shi12:24 7 Aug '08  
QuestionCoInitializeEx Pinmembermeouvn17:54 8 Sep '05  
AnswerRe: CoInitializeEx Pinmembersswater shi18:42 8 Sep '05  
Generalbad zip file Pinmembercstudy6:23 17 Jun '04  
GeneralRe: bad zip file Pinmembersswater10915:01 17 Jun '04  
GeneralRe: bad zip file Pinmembercstudy0:23 2 Jul '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 1 Mar 2004
Article Copyright 2004 by sswater shi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid