Menu

#11 Problem: Using regular expression with --match-d option

v1.61
closed
nobody
None
1
2015-06-27
2014-08-15
Anonymous
No

In my computer, structure of folder that contains multiple source file is as follow:

D:\test\interfaces\codex\A\ D:\test\interfaces\codex\B\
D:\test\sources\code\X
D:\test\sources\code\Y
D:\test\boot\M\
D:\test\boot\N\

I want to count all sources files in subfoler A,B,X,Y,Z. I realize that these subfolders belong to folder "code" and "codex". Therefore, I use this command line:

cloc --by-file --force-lang-def=filter.txt --skip-uniqueness --match-d='/(code|codex)/' --exclude-dir=boot "D:\test" --out=count.txt

However, it does NOT work. I did not find any source files to count. It returns:
0 text files
0 unique files
0 files ignored

When I try to find source code in one folder only (for exampale: code), using regular expression, it still did NOT work:

cloc --by-file --force-lang-def=filter.txt --skip-uniqueness --match-d='/code/' --exclude-dir=boot "D:\test" --out=count.txt

But if I change to following one (NOT use regular expression), it works for me:

cloc --by-file --force-lang-def=filter.txt --skip-uniqueness --match-d=code --exclude-dir=boot "D:\test" --out=count.txt

Could you please helping me to solve this problem? Thank you.

Discussion

  • Al Danial

    Al Danial - 2014-08-15

    I duplicated your directory tree on a Linux machine and found this works:

    cloc --by-file --match-d='(code|codex)' --exclude-dir=boot  test
    

    so try removing the /'s from your --match-d regex as the code is looking for those. Also, you might hit problems in the future if you put optional arguments after the directory names to work on. In other words, instead of

    cloc --by-file --force-lang-def=filter.txt --skip-uniqueness --match-d=code --exclude-dir=boot "D:\test" --out=count.txt
    

    put the input directory, D:\test, last:

    cloc --by-file --force-lang-def=filter.txt --skip-uniqueness --match-d=code --exclude-dir=boot --out=count.txt  "D:\test"
    
     
  • Al Danial

    Al Danial - 2015-02-26
    • status: open --> pending
     
  • Al Danial

    Al Danial - 2015-06-27
    • status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel