1

This is the 'C' version of my previous old+java question Can java.util.regex.Pattern do partial matches?

Is it possible to know if a string contains an input that could match a regular expression using the regcomp/regexec/regfree library.

e.g:

 input : "AA";
 regex : "AAAAAB";
 //<-- regexec returns true ?

and

 input : "BB";
 regex : "AAAAAB";
 //<-- regexec returns false ?
Community
  • 1
  • 1
Pierre
  • 34,472
  • 31
  • 113
  • 192
  • Looks like there is no support for this. In Boost for C++, there is a partial_match though: http://www.boost.org/doc/libs/1_31_0/libs/regex/doc/partial_matches.html – Wiktor Stribiżew Apr 07 '15 at 14:56
  • @Pierre Probably should MCVE. Not sure if you mean the regex examples to be bound ^RE$ or not. I would write the regex pattern to be matched as (_assuming bound as ^AAAAAB$_) `"^(A{1,5})?(B?)$"`. That is to say an optional string of 1 to 5 A's, followed by an optional B. A single `A` would match, as would a single `B`. `AB` would also match, as well as 2-5 A's. Unfortunately the empty string would also match in my example. – Deathgrip May 29 '17 at 22:30

0 Answers0