Add wxRegEx::QuoteMeta() helper
Quote all characters special for wxRegEx in the given string: this can be useful when searching for a literal string using wxRegEx. Closes https://github.com/wxWidgets/wxWidgets/pull/1489
This commit is contained in:
@@ -334,5 +334,14 @@ CPPUNIT_TEST_SUITE_REGISTRATION(wxRegExTestSuite);
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(wxRegExTestSuite, "wxRegExTestSuite");
|
||||
|
||||
TEST_CASE("wxRegEx::QuoteMeta", "[regex][meta]")
|
||||
{
|
||||
CHECK( wxRegEx::QuoteMeta("") == "" );
|
||||
CHECK( wxRegEx::QuoteMeta("a") == "a" );
|
||||
CHECK( wxRegEx::QuoteMeta("?") == "\\?" );
|
||||
CHECK( wxRegEx::QuoteMeta("\\") == "\\\\" );
|
||||
CHECK( wxRegEx::QuoteMeta("\\?!") == "\\\\\\?!" );
|
||||
CHECK( wxRegEx::QuoteMeta(":foo.*bar") == ":foo\\.\\*bar" );
|
||||
}
|
||||
|
||||
#endif // wxUSE_REGEX
|
||||
|
Reference in New Issue
Block a user