tags:

views:

45

answers:

1

I want to write simple program in C equivalent to the regular expression:

/<rr>(.*?)<\/rr>/<test>$1<\/test>/gi. 

Does anyone have examples?

A: 

It helps if you understand what the regex is supposed to do.

The pattern

The parentheses (...) indicate the beginning and end of a group. They also create a backreference to be used later.

The . is a metacharacter that matches any character.

The * repetition specifier can be used to match "zero-or-more times" of the preceding pattern.

The ? is used here to make the preceding quantifier "lazy" instead of "greedy."

The $1 is likely (depends on the language) a reference to the first capture group. In this case it would be everything matched by (.*?)

The /g modifier at the end is used to perform a global match (find all matches rather than stopping after the first match).

The /i modifier is used to make case-insensitive matches

References

NullUserException