Change regex to match .java and .mm files

I am trying to use a cscope-indexer script. But I want to know how to change the following to include *.mm

and *.java

files?

egrep -i '\.([chly](xx|pp)*|cc|hh)$' | \
sed -e '/\/CVS\//d' -e '/\/RCS\//d' -e 's/^\.\///' | \
sort > $LIST_FILE

      

I tried

egrep -i '\.([chly](xx|pp)*|cc|hh|mm|java)$'

      

he does not work.

0


a source to share


2 answers


Try:



egrep -i '\.([chly](xx|pp)*|cc|hh|mm|java)$' | \
sed -e '/\/CVS\//d' -e '/\/RCS\//d' -e 's/^\.\///' | \
sort > $LIST_FILE

      

+2


a source


When you saw [chly] in the original regex, it meant either "c", "h", "l", or "y". When it was changed to "chly *" it now meant "chl" followed by any number of y. Also, when you removed the "\" from before the first period, you changed its "match a period" value to "match one of the characters".



For more information on regular expressions, check out the Perl Regular Expression Guide , as Perl pretty much came up with regular expressions.

0


a source







All Articles