Reputation: 38126
the regex i am using is for an implementation of preprocessor, in flex. This preprocessor is kindof simple. It obeys following rules:
#
sign.for example:
#define CONSTANT 100
//...
int x = #CONSTANT;
so first thing i did was
#define {
//store the identifier following #define in a lookup table
//do the relevant error checking
}
NO_POUND_DEFINE {
//The string should begin with a '#' sign but not with `#define`
//check if the string following '#' is upper case or not
//if in upper case do the lookup otherwise throw an error
}
Upvotes: 1
Views: 309
Reputation: 10170
var regexp = /^((?!#define).)*$/;
Maybe you want to take a look at this: regular-expression-to-match-string-not-containing-a-word
Upvotes: 2
Reputation: 2878
^#([^d]|d[^e]|de[^f]|def[^i]|defi[^n]|defin[^e]).*
The string starts with a '#' not followed by a 'd' or followed by a 'd' but not followed by an 'e' etc.
Upvotes: 1