You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case you do not have C++11 compliant standard library you can still use boost.regex.
Examples
Here's a couple of simple examples to give an idea of how VerbalExpressions works:
Testing if we have a valid URL
// Create an example of how to test for correctly formed URLs
verex expr = verex()
.search_one_line()
.start_of_line()
.then( "http" )
.maybe( "s" )
.then( "://" )
.maybe( "www." )
.anything_but( "" )
.end_of_line();
// Use verex's test() function to find if it matches
std::cout << expr.test("https://www.google.com") << std::endl;
// Ouputs the actual expression used: ^(?:http)(?:s)?(?:://)(?:www.)?(?:[^ ]*)$
std::cout << expr << std::endl;
Replacing strings
// Create a test string
std::string replaceMe = "Replace bird with a duck";
// Create an expression that seeks for word "bird"
verex expr2 = verex().find("bird");
// Execute the expression
std::cout << expr2.replace(replaceMe, "duck") << std::endl;
Shorthand for string replace:
std::cout << verex().find( "red" ).replace( "We have a red house", "blue" ) << std::endl;
Here you can find the API documentation for Verbal Expressions
Basic usage
Basic usage of Verbal Expressions starts from the expression verex(). You can chain methods afterwards. Those are described under the "terms" section.