Tuesday 15 January 2013

pattern matching / extracting in c using regex.h -


I need help in removing a substrings from a string using regex.h in C. In this example, I am trying to remove all the incidents of character 'E' from string 'telephone', unfortunately, I get caught in recognizing the offset of those letters. I am the code listed below:

  #include & lt; Stdio.h & gt; # Include & lt; Regex.h & gt; Int main (zero) {const int size = 10; Regex_t regex; Regmatch_t matchstruct [shape]; Four patterns [] = "(e)"; Char str [] = "telephone"; Complete failure = regcomp (& amp; regex; pattern, REG_EXTENDED); If (failure) {printf ("can not compile"); } ET Match Failure = Reggaek (and Rijks, Pattern, Size, Matchstruck, 0); If (! Matchfileer) {printf ("\ n match !!"); } Other {printf ("no match !!"); } Return 0; }  

So for every GNU manual, I should get all the events of 'E', when a letter is made of brackets. However, I always get only the first event.

Basically, I want to see something like this:

  matchstruct [1]. Rm_so = 1; Matchstrack [1] Rm_so = 2; Matchstrack [2] Rm_so = 4; Matchstore [2] Rm_so = 5; Matchstore [3]. Rm_so = 7; Matchstore [3]. Rm_so = 8;  

Or some advice with these lines?

Please note that you can actually enter str ("telephone") Check your second attribute on regexec instead of your plain-text pattern , for example, "for example" where your question has already been answered. "


No comments:

Post a Comment