Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > BOOK: Beginning Regular Expressions
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Regular Expressions
This is the forum to discuss the Wrox book Beginning Regular Expressions by Andrew Watt; ISBN: 9780764574894
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Regular Expressions section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 31st, 2010, 08:36 AM
Registered User
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find class references in C++ file

I'm trying to match all class references in a C++ file using grep with regular expression. I'm trying to know if a specific include is usuless or not, so I have to know if there is a refence in cpp.
I wrote this RE that searches for a reference from class ABCZ, but unfortunately it isn't working as I espected:

PHP Code:
grep -'^[^(\/\*)(\/\/)].*[^a-zA-Z]ABCZ[]*[\*\(\<:;,{& ]' 
^[^(\/\*)(\/\/)] don't math comments in the begging of the line ( // or /* )
.* followed by any character
[^a-zA-Z] do not accept any caracter before the one I'm searching (like defABCZ)
[]* any white space (I can have something like ABCZ var;)
[\*\(\<:;,{& ] followed by ( * < : ; , & { (I cant get #define "ABCZ.h" or ABCZdef for example)

Well, I can get patterns like this:

PHP Code:
class Test: public ABCZ{
Test: public ABCZ {
Test :public ABCZ<T>
class NameSpace::
Test :public ABCZ<T>
ABCZ var = ABCZ();
ABCZ* var = new ABCZ();
ABCZ* var = new ABCZ<T>();
teste ABCZ(var);
teste ABCZ(var, otherVar);
teste ABCZ(var,otherVar);
teste =     ABCZ();
funct(*ABCZ av);
ABCZgetNot_before(void) const; 
That's all right, they are all acceptable patterns. But these I'm missing, and they are all acceptable too:

PHP Code:
ABCZ        teste;
ABCZ        teste//comment
ABCZ        teste/* comment*/
ABCZ teste/* comment*/
ABCZ teste;
ABCZ *teste
And all these are not acceptable:
PHP Code:
#include "ABCZ.h"
//ABCZ var = ABCZ();
ABCZdef a ABCZdef();
DefABCZ a DefABCZ();
ABCZdef a ABCZdef();
/*ABCZ var = ABCZ(); 
I don't know if I'm missing any other patterns, if I am, please tell me =p
What am I doing wrong?
I'll be very grateful if someone answer me :)
Thanks in advance

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
class file thas123 ASP.NET 2.0 Basics 0 December 13th, 2006 03:45 AM
Regarding Class Library (.dll) from class file manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 March 3rd, 2006 07:32 AM
Appletviewer can't find class...but IE works fine dperry BOOK: Beginning Java 2, JDK 5 Edition 0 July 7th, 2005 10:44 AM
Find file with _ in it dunnie Pro VB 6 1 April 23rd, 2004 05:43 AM
ClassWizard can't find Class Gert Visual C++ 3 October 16th, 2003 03:59 AM

All times are GMT -4. The time now is 10:57 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.