tags:

views:

48

answers:

2

I've got a regex pattern which I am using to match files having particular extensions. However I do NOT want it to match any .Designer.cs files; how would I implement such into my pattern?

\.(bat|cs|java|html|etc)$

+3  A: 

You need to use a negative look-behind, like this:

(?<!\.Designer)\.(bat|cs|java|html|etc)$
SLaks
Thanks. I used a slight variation so it does not match .Designer.cs but could match .Designer.java, for example: `\.((?<![dD]esigner\.)cs|java|bat)$`I will accept your answer once the limit is up.
Jake Petroules
A: 

there are some "online regex" - Tester. I was successful with:

.*(?<!.designer)(\.bat|\.cs|\.java|\.html|\.etc)$

(only milliseconds too late ... :-(

ralf.w.