Let's assume that we have the next directory structure:
/parentdir/
/ch开发者_StackOverflow中文版ilddir/
child_file1.txt
child_file2.jar
file1.txt
file2.txt
so, we get next full file names:
/parentdir/file1.txt
/parentdir/file2.txt
/parentdir/childdir/child_file1.txt
/parentdir/childdir/child_file2.jar
Which regular expression matches all of these files except for the last one with .jar extension?
Little clarification: expression can contain 'parentdir' string and '.jar' string, all other files and directories can have any names and extensions.
You can use negative assertions : /(?<!\.jar)$/
That would match anything that doesn't end in .jar
The negative assertion regex is one way to go, but the more common solution for this in mercurial land is to ignore broadly (for example just ignore parentdir/
) and then hg add
the few exception files you don't wanted ignored.
In svn and cvs you can't add a file that's in your ignore list and if you do future changes aren't tracked, but in mercurial hg add
completely overrides ignore, so unless you'll have many new jars showing up in the future, just ignore broadly and add the .jar.
精彩评论