![]() ![]() ![]() Boost.Xpressive provides the operator operator>, which is used in Example 9.3. Otherwise, the result wouldn’t be valid C++ code. While “ \w” and “ \s” can be written one after another in a string, objects like _w and _s must be concatenated with an operator. For example, the object _w is similar to “ \w”. The library provides objects for character groups. Both examples search for at least one alphanumeric character followed by one space followed by at least one alphanumeric character.īoost.Xpressive makes it possible to write regular expressions with C++ code. It is exactly the same regular expression. Compare this with Example 9.2, where the regular expression is applied to a string of type const char*. Because s is based on std::string in Example 9.1, the type of the regular expression must be boost::xpressive::sregex. The type of the regular expression in Boost.Xpressive depends on the type of the string being searched. However, there is a fundamental difference between Boost.Xpressive and Boost.Regex. ![]() You can see this in Example 9.1, which uses the function boost::xpressive::regex_match(), and which looks similar to Example 8.1. boost::xpressive::regex_match() compares strings, boost::xpressive::regex_search() searches in strings, and boost::xpressive::regex_replace() replaces characters in strings. Std::cout << std::boolalpha << regex_match(s, expr) << '\n' īoost.Xpressive basically provides the same functions as Boost.Regex, except they are defined in the namespace of Boost.Xpressive. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |