Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
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

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

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