Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a match_partial in C++11 Regular Expressions?

I read through n1429 with the section

The algorithms regex_match and regex_search both support a feature not commonly seen in regular expression libraries: a partial match. When the flag std::regex_constants::match_partial is set in the flags passed to the algorithm, then a result of true may be returned if one or more characters were matched, and the state machine then reached the end of the character sequence while there were still states to be matched. [...]

But I can not find any trace of that feature in the FCD, nor in the headers of the current gcc-4.7.0. I also looked for a revision of n1429 but again did not find anything. I know that the basis for the proposal had it's origins in Boost and made it into TR1. But I do not know when match_partial disappeared.

Is the partial match feature still in C++11? Maybe with a different name?

like image 272
towi Avatar asked Oct 08 '11 09:10

towi


People also ask

Can regular expression have Epsilon?

Operands in a regular expression can be: characters from the alphabet over which the regular expression is defined. variables whose values are any pattern defined by a regular expression. epsilon which denotes the empty string containing no characters.

Is there regex in C++?

C++ has direct support for regexes from C++11 onwards. Apart from programming languages, most of the text processing programs like lexers, advanced text editors, etc. use regexes.

Are there regular expressions in C?

A regular expression is a sequence of characters used to match a pattern to a string. The expression can be used for searching text and validating input. Remember, a regular expression is not the property of a particular language. POSIX is a well-known library used for regular expressions in C.

What is [] in regular expression?

The [] construct in a regex is essentially shorthand for an | on all of the contents. For example [abc] matches a, b or c. Additionally the - character has special meaning inside of a [] . It provides a range construct. The regex [a-z] will match any letter a through z.


1 Answers

It seems the match_partial flag is removed in N1723 "Proposed Resolutions to Library TR Issues" (2004 Oct) as a resolution to N1507 "Errata to the Regular Expression Proposal":

7.34 Meaning of the match_partial flag

Remove match_partial.

The rationale according to N1837 "Library Extension Technical Report  Issues List" is that:

The LWG agrees that this is a useful and implementable feature, but we have repeatedly tried and failed to give it an adequate specification. We hope that it will be possible to add this feature in a future version.

I guess there's no replacement in C++11. You can still use Boost.Regex though (where std::regex comes from), which supports partial match.

like image 163
kennytm Avatar answered Oct 26 '22 22:10

kennytm