Using grep and regular expression to find class references in a c++ file
I'm trying to math 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:
^[^(\/\*)(\/\/)] 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:
Quote:
class Test: public ABCZ{
class Test: public ABCZ {
class 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);
struct(ABCZ, BBBB, CCCC);
const ABCZ& getNot_before(void) const;
That's all right, they are all acceptable patterns. But these I'm missing, and they are all acceptable too:
And all these are not acceptable:
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
Last edited by vbe; 05-28-2010 at 12:42 PM..
Reason: Code tags please
Hello Everyone,
I have a file sam1 with the below content
SYSYSID;MANDT;/SIE/AD_Z0M_INDX;/SIE/AD_Z0M_KEY1
echo $Regex
\bSYSYSID\b|\bMANDT\b|\b/SIE/AD_Z0M_INDX\b|\b/SIE/AD_Z0M_KEY1\b
cat sam1 | grep -Eo $Regex
I expect the result as
SYSYSID
MANDT
/SIE/AD_Z0M_INDX
/SIE/AD_Z0M_KEY1... (4 Replies)
Hi Gurus,
I need to identify the file with below format:
ABC20110101.DAT
ABCD2011010103.DAT
If I use ABC*\.DAT, it get two file. I want to get file after "ABC' then number, the ".DAT".
I tried
ABC* but it doesn't work.
Thanks in advance. (9 Replies)
Hi ,
I have few lines like
A20120101.ANU.ZIP
A20120401.ABC.ZIP
A20120105.KJK.ZIP
A20120809.JUG.ZIP
A20120101.MAT.ZIP
B20120301.ANU.XIP
I want to filter by
1. Files starting with A and Ending With Z ( ^A.*.ZIP$)
2. And either ANU, or KJK or MAT in the file name.
Hope my... (6 Replies)
Hi all
I have a list of file names in array. But this file names are not exact. so i want to search whether a file exists or not using regular expression.
code snippet:
if ;
then
echo "File exists"
else
echo "File does not exits"
fi
over here "*EQST*" should be treated as a regular... (4 Replies)
Hi all,
How am I read a file, find the match regular expression and overwrite to the same files.
open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat";
open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat";
while (<DESTINATION_FILE>)
{
# print... (1 Reply)
Hi all ,
I'm new to unix
I have a checked project , there exists a file called xxx.config .
now my task is to find all the files in the checked out project which references to this xxx.config file.
how do i use grep or find command . (2 Replies)
I suspect this is commonly done, but haven't found the right combination of search terms to find the answer.
I want to grep for lines in .cpp files that contain only 1 '=' sign in an if statement. e.g.,
if (a = b) -- find this
if (a==b) -- don't find this
My attempt:
egrep... (7 Replies)
Hi, guys. I have one question, hope somebody can give me a hand
I have a file called passwd, the contents of it arebelow:
***********************
...
goldsimj:x:5008:200:
goldsij2:x:5009:200:
whitej:x:5010:201:
brownj:x:5011:202:
goldsij3:x:5012:204:
greyp:x:5013:203:
...... (6 Replies)
guys,
my requirment goes like this:
I have a file, and wish to filter out records where
1. The first letter is o or O
and
2. The next 4 following letter should not be ther
I do not wish to use pipe and wish to do it in one shot.
The best expression I came up with is:
grep ^*... (10 Replies)