Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex to select all .c files except ones with a certain prefix

Tags:

regex

makefile

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.

like image 945
cdietschrun Avatar asked Apr 16 '11 16:04

cdietschrun


2 Answers

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))
like image 83
eriktous Avatar answered Oct 09 '22 22:10

eriktous


^[^(ttem_endian_port)]*.c
  • The first ^ means 'beginning of string'.
  • Then, you need to parenthesize ttem_endian_port to make the regexp engine understand that you want to negate the whole term with your ^
like image 21
Elad Avatar answered Oct 09 '22 23:10

Elad