Click here to Skip to main content
Click here to Skip to main content

Convenient wrapper of VBScript.RegExp for VC++

By , 29 Feb 2004
 

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionCan I use the object from STA?memberAndreBroz3 Apr '12 - 4:50 
AnswerRe: Can I use the object from STA?membersswater shi3 Apr '12 - 16:45 
GeneralWorks Wellmembertimbolicus_prime7 Aug '08 - 7:15 
GeneralRe: Works Wellmembersswater shi7 Aug '08 - 12:24 
QuestionCoInitializeExmembermeouvn8 Sep '05 - 17:54 
AnswerRe: CoInitializeExmembersswater shi8 Sep '05 - 18:42 
Generalbad zip filemembercstudy17 Jun '04 - 6:23 
GeneralRe: bad zip filemembersswater10917 Jun '04 - 15:01 
GeneralRe: bad zip filemembercstudy2 Jul '04 - 0:23 

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

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