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:
parent
363cdc5fdc
commit
050ca4ce3a
4 changed files with 62 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue