RegEx gods requiered

How do you match a regex to any string of characters but include some strings that must not match?

Say I have a block of C code and I want to wrap every function call with another function. The problem is that functions have the same form as operators such as main(), if(), etc. and

Basically, I need to match every \w*\(.*\) except main(), if() and the likes.

Other urls found in this thread:

stackoverflow.com/questions/1395177/regex-to-exclude-a-specific-string-constant
twitter.com/SFWRedditImages

Use a fucking parser generator instead dipshit.

like for example...

I don't even know what you're trying to even do but it sounds like you want to do some form of parsing instead of trying to wrangle convoluted shit language like PCRE to do something that is better done In sane parser generated languages like PEG, BNF, etc.

There are tons of PEG generators for a shitload of languages, peg.js, some ruby bullshit, etc.

That will be a bitch, user.
stackoverflow.com/questions/1395177/regex-to-exclude-a-specific-string-constant

If you have the time, use some parser generator, like said.
For some popular ones like ANTLR you might even find grammar files for C etc.
Also it might be worth pursuing to hack a pretty printer.

You need to include a lot more information in your question. I'm assuming you're using a programming language. If that's the case, the easiest way (that those new to regex never think of, for some reason) is to just negate the match in the language.

Shitty pseudocode example:
for (line in file) {
if (!myLine.matches(functionCallRegex)) {
continue;
}
if (line.matches(prohibitedStringsRegex)) {
continue;
}
// Process the line
}

Thanks a lot user.

Thing is I just found a sweet way of profiling my code inspired in python decorators (the @ thing)

Now I just need to wrap all my functions in my "decorator" macro, but obviously have to skip the operators.

It sounds like the sort of thing a regex could do to the c file.

Oops, change "myLine" to "line", but you should get the idea. Match what you *don't want* and then ignore the line if it matches.

>python spacing
post disregarded

The fuck are you talking about? Isn't "python spacing" 4-space indentation? (Which that post doesn't use) I've never heard of someone complaining about it.

Paste some example code and I'll try to work my RegEx magic.

>posting xkcd
ignore this guy, his regexes probably suck

They probably will, but if it can be done in RegEx I can do it. Probably.

Never mind, spoken like a true regex user. Carry on, then

int main(){
printf(" a's value: %d \n pointer to a's value: %d \n", a, *b);
DoSomething(something_else());
int *b = do_some(arg_1, arg_2);
if(do_something(arg1)){
a = b + 1;
}
else{
exit(1);
}

return 0;
}


Here we go. wrap every function call in a function-like macro called profile, except operators like main(), if(), while(), switch, case, etc.

You read the manual.

YOU TOO LAZY TO gOOGLE THE answer, FaggoT?

>I've never heard of someone complaining about it.
You still haven't. That was a nobody.

Thank you for not python spacing.

First to solve this gets my nudes (I'm a girl btw xoxo)

I don't get the joke.
What's up with Perl users and Regex?

(?!^.*[(]{1,}.*$)^.*

((?!^.*[main(]{5,})(?!^.*[if(]{3,}.*)(?!^.*[while(]{6,}.*)(?!^.*[switch]{6,}.*)(?!^.*[case]{4,}.*))^.*

perl does basically everything with regex.

Is profile going to play nicely with macros?