Reputation: 7143
I would like to perform regular expression in C . Suppose I have following text like:
thecapital([x], implies(maincity(y),x))
The program has to output like:
implies(maincity(y),x))
can anyone please suggest how shall I proceed?
Upvotes: 0
Views: 459
Reputation: 41627
To transform the input string thecapital([x], implies(maincity(y),x))
to the output string implies(maincity(y),x))
you can use the following simple function:
const char *
transform(const char *expr) {
return expr + 16;
}
It doesn't use regular expressions, but on the other hand it's lightning fast. Or maybe you didn't put your question clearly. For example, you didn't describe in words what transformation should be done. Giving just one example is not enough.
So what do you really want to do:?
i
"implies(maincity(y),x))"
For your one example my simple suggested function fulfills all these requirements. But of course it will fail hopelessly when given any other input.
Upvotes: 4