Reputation: 1683
I have what should be a real simple regex question. I'm making a makefile and need one target to compile all the source in my directory except one or two files that have a named prefix of ttem_endian_port. What regex can I use to make this as simple as possible?
I was thinking something like [^ttem_endian_port*]*.c but that doesn't seem to work.
Upvotes: 13
Views: 8944
Reputation: 4635
Regexp were not made to do a negative search. If you really want to use regexp, you can make a lookahead (not all the engines support it):
^(?!ttem_endian_port).*\.c$
Also, don't forget to escape the dot. Look at this question for more information.
Upvotes: 2
Reputation: 6659
Do you really need a regex? make
's built-in functions can do this as well.
ALL_SRCS := $(wildcard *.c) SRCS := $(filter-out ttem_endian_port%.c, $(ALL_SRCS))
Upvotes: 17
Reputation: 3130
^[^(ttem_endian_port)]*.c
Upvotes: 2