Initial commit of v4 of boost.regex on regex-4 branch

[SVN r18128]
This commit is contained in:
John Maddock
2003-03-29 12:29:57 +00:00
parent 3c00a90080
commit d80d6ffc09
81 changed files with 14574 additions and 359 deletions
+52
View File
@@ -0,0 +1,52 @@
/*
*
* Copyright (c) 1998-2002
* Dr John Maddock
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Dr John Maddock makes no representations
* about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: recursion_test.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Test for indefinite recursion and/or stack overrun.
*/
#include <string>
#include <boost/regex.hpp>
#include <boost/test/test_tools.hpp>
int test_main( int argc, char* argv[] )
{
std::string bad_text(1024, ' ');
std::string good_text(200, ' ');
good_text.append("xyz");
boost::smatch what;
boost::regex e1("(.+)+xyz");
BOOST_CHECK(boost::regex_search(good_text, what, e1));
BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e1), std::runtime_error);
BOOST_CHECK(boost::regex_search(good_text, what, e1));
BOOST_CHECK(boost::regex_match(good_text, what, e1));
BOOST_CHECK_THROW(boost::regex_match(bad_text, what, e1), std::runtime_error);
BOOST_CHECK(boost::regex_match(good_text, what, e1));
boost::regex e2("abc|[[:space:]]+xyz");
BOOST_CHECK(boost::regex_search(good_text, what, e2));
BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e2), std::runtime_error);
BOOST_CHECK(boost::regex_search(good_text, what, e2));
return 0;
}
+63
View File
@@ -0,0 +1,63 @@
/*
*
* Copyright (c) 1998-2002
* Dr John Maddock
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Dr John Maddock makes no representations
* about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: recursion_test.cpp
* VERSION: see <boost/version.hpp>
* DESCRIPTION: Test for indefinite recursion and/or stack overrun.
*/
#include <string>
#include <boost/regex.hpp>
#include <boost/test/test_tools.hpp>
int test_main( int argc, char* argv[] )
{
// this regex will recurse twice for each whitespace character matched:
boost::regex e("([[:space:]]|.)+");
std::string bad_text(1024*1024*4, ' ');
std::string good_text(200, ' ');
boost::smatch what;
//
// Over and over: We want to make sure that after a stack error has
// been triggered, that we can still conduct a good search and that
// subsequent stack failures still do the right thing:
//
BOOST_CHECK(boost::regex_search(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_search(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_search(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_search(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_search(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_search(good_text, what, e));
BOOST_CHECK(boost::regex_match(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_match(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_match(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_match(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_match(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_match(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_match(good_text, what, e));
BOOST_CHECK_THROW(boost::regex_match(bad_text, what, e), std::runtime_error);
BOOST_CHECK(boost::regex_match(good_text, what, e));
return 0;
}
+2 -1
View File
@@ -10,7 +10,7 @@ CXX= g++ $(INCLUDES) -I../../../../ -I./ $(CXXFLAGS) -L../../build/gcc $(LDFLAGS
SOURCES=tests.cpp parse.cpp regress.cpp ../../../test/src/cpp_main.cpp ../../../test/src/execution_monitor.cpp
total : gcc_regress
./gcc_regress tests.txt
export LD_LIBRARY_PATH="../../build/gcc:$LD_LIBRARY_PATH" && ./gcc_regress tests.txt
gcc_regress : $(SOURCES)
$(CXX) -O2 -o gcc_regress $(SOURCES) -lboost_regex $(LIBS)
@@ -59,5 +59,6 @@ debug : $(SOURCES)
+8 -4
View File
@@ -65,9 +65,13 @@ flag_info flag_data[] = {
{ BOOST_RE_STR("bk_vbar"), 7, regbase::bk_vbar, 2 },
{ BOOST_RE_STR("use_except"), 10, regbase::use_except, 2 },
{ BOOST_RE_STR("literal"), 7, regbase::literal, 2 },
#ifndef BOOST_REGEX_V3
{ BOOST_RE_STR("perlex"), 6, regbase::perlex, 2 },
#endif
{ BOOST_RE_STR("normal"), 6, regbase::normal, 2 },
{ BOOST_RE_STR("basic"), 5, regbase::basic, 2 },
{ BOOST_RE_STR("extended"), 8, regbase::extended, 2 },
{ BOOST_RE_STR("perl"), 6, regbase::perl, 2 },
{ BOOST_RE_STR("match_default"), 13, match_default, 3 },
{ BOOST_RE_STR("match_not_bol"), 13, match_not_bol, 3 },
@@ -94,6 +98,7 @@ flag_info flag_data[] = {
{ BOOST_RE_STR("REG_GREP"), 8, REG_GREP, 4 },
{ BOOST_RE_STR("REG_MERGE"), 9, REG_MERGE, 4 },
{ BOOST_RE_STR("REG_MERGE_COPY"), 14, REG_MERGE_COPY, 4 },
{ BOOST_RE_STR("REG_PARTIAL_MATCH"), 17, REG_PARTIAL_MATCH, 4 },
{ BOOST_RE_STR(""), 0, 0, 0 },
};
@@ -104,12 +109,11 @@ flag_info flag_data[] = {
const char_t* expression_text = BOOST_RE_STR("(;.*)|") // comment
BOOST_RE_STR("(^[[:blank:]]*-)|") // -
BOOST_RE_STR("([^\"[:space:]][^[:space:]]*)|") // token
BOOST_RE_STR("(\"(([^\"]|\\\\\")*)\")") // "token"
BOOST_RE_STR("(\"((\\\\\"|[^\"])*)\")") // "token"
;
typedef reg_expression<char_t> re_parse_t;
typedef re_parse_t::allocator_type parse_alloc;
typedef match_results<string_type::const_iterator, parse_alloc> parse_grep;
typedef basic_regex<char_t> re_parse_t;
typedef match_results<string_type::const_iterator> parse_grep;
typedef string_type::const_iterator parse_iterator;
re_parse_t parse_expression(expression_text, regbase::normal);
+2 -2
View File
@@ -64,7 +64,7 @@ regbase::flag_type f = regbase::escape_in_lists | regbase::char_classes | regbas
template class reg_expression<test_char_type>;
template struct sub_match<ra_it>;
template class match_results<ra_it>;
#if 0
template bool regex_match(ra_it,
ra_it,
match_results<ra_it>& m,
@@ -169,7 +169,7 @@ template test_string_type regex_merge(const test_string_type&,
unsigned int flags);
#endif
#endif
} // namespace boost
//
+4 -4
View File
@@ -81,10 +81,10 @@ int cpp_main(int argc, char * argv[])
{
#if defined(BOOST_MSVC) && defined(_DEBUG)
// turn on heap reporting at program exit:
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
tmpFlag &= ~_CRTDBG_CHECK_CRT_DF;
_CrtSetDbgFlag( tmpFlag );
//int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
//tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
//tmpFlag &= ~_CRTDBG_CHECK_CRT_DF;
//_CrtSetDbgFlag( tmpFlag );
#endif
#ifdef TIME_TEST
boost::timer tim;
+7 -5
View File
@@ -418,20 +418,22 @@ __iterator_category(const debug_iterator<T>&) {
#define BOOST_RE_TEST_LOCALE_W32
#endif
#ifdef BOOST_REGEX_V3
# define basic_regex reg_expression
#endif
#ifdef BOOST_RE_TEST_LOCALE_W32
typedef boost::reg_expression<char_t, boost::w32_regex_traits<char_t>, jm_debug_alloc> re_type;
typedef boost::basic_regex<char_t, boost::w32_regex_traits<char_t>, jm_debug_alloc> re_type;
#elif defined(BOOST_RE_TEST_LOCALE_CPP)
typedef boost::reg_expression<char_t, boost::cpp_regex_traits<char_t>, jm_debug_alloc> re_type;
typedef boost::basic_regex<char_t, boost::cpp_regex_traits<char_t>, jm_debug_alloc> re_type;
#else
typedef boost::reg_expression<char_t, boost::c_regex_traits<char_t>, jm_debug_alloc> re_type;
typedef boost::basic_regex<char_t, boost::c_regex_traits<char_t>, jm_debug_alloc> re_type;
#endif
#define REG_NO_POSIX_TEST 1
#define REG_UNICODE_ONLY 2
#define REG_GREP 4
#define REG_MERGE 8
#define REG_MERGE_COPY 16
#define REG_PARTIAL_MATCH 32
#endif
+89 -36
View File
@@ -37,8 +37,10 @@ bool compare_result(const M1& sm, const M2& m)
{
if(sm.size() != m.size())
return false;
#ifdef BOOST_REGEX_V3
if(sm.line() != m.line())
return false;
#endif
for(unsigned int i = 0; i < sm.size(); ++i)
{
if(sm.position(i) != m.position(i))
@@ -57,7 +59,7 @@ bool compare_result(const M1& sm, const M1& m)
template <class C, class T, class A>
void cpp_eh_tests(const reg_expression<C, T, A>& )
void cpp_eh_tests(const basic_regex<C, T, A>& )
{
#ifndef __GNUC__
bool thrown = false;
@@ -67,7 +69,7 @@ void cpp_eh_tests(const reg_expression<C, T, A>& )
{
#endif
A a;
reg_expression<C, T, A> e(a);
basic_regex<C, T, A> e(a);
e.set_expression(expression.c_str(), flags[2] | regbase::use_except);
#ifndef BOOST_NO_EXCEPTIONS
}
@@ -90,7 +92,7 @@ void cpp_eh_tests(const reg_expression<C, T, A>& )
#endif
{
A a;
reg_expression<C, T, A> e(expression.c_str(), flags[2] | regbase::use_except, a);
basic_regex<C, T, A> e(expression.c_str(), flags[2] | regbase::use_except, a);
}
#ifndef BOOST_NO_EXCEPTIONS
catch(const boost::bad_expression&)
@@ -142,14 +144,20 @@ class grep_test_predicate
{
int match_id;
iterator base, term;
// rebind allocator to correct type:
#ifdef BOOST_REGEX_V3
typedef Alloc alloc_type;
#else
typedef typename detail::rebind_allocator<boost::sub_match<iterator>, Alloc>::type alloc_type;
#endif
public:
grep_test_predicate(iterator i, iterator j) : base(i), term(j) { match_id = 0; }
~grep_test_predicate(){}
bool operator()(const boost::match_results< iterator, Alloc >& m);
bool operator()(const boost::match_results< iterator, alloc_type >& m);
};
template <class iterator, class Alloc>
bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results< iterator, Alloc >& m)
bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results< iterator, alloc_type >& m)
{
std::ptrdiff_t start, end;
start = m[0].first - base;
@@ -189,6 +197,7 @@ bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results
//
// now check line()
/* don't check this, it's not supported in the new algorithm....
start = m.line();
end = count_lines(base, iterator(m[0].first)) + 1;
if(start != end)
@@ -196,9 +205,10 @@ bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results
begin_error();
cout << "regex++ grep error in line(): found " << start << " expected " << end << endl;
}
*/
//
// now check line_start()
/* don't check this, it's not supported in the new algorithm....
start = m.line_start() - base;
end = find_last_line(base, iterator(m[0].first)) - base;
if(start != end)
@@ -206,22 +216,22 @@ bool grep_test_predicate<iterator, Alloc>::operator()(const boost::match_results
begin_error();
cout << "regex++ grep error in line_start(): found " << start << " expected " << end << endl;
}
*/
match_id += 2;
return true;
}
template <class C, class T, class A>
void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
void cpp_tests(const basic_regex<C, T, A>& e, bool recurse = true)
{
typedef typename reg_expression<C, T, A>::allocator_type allocator_type;
typedef typename basic_regex<C, T, A>::allocator_type allocator_type;
if(flags[4] & REG_MERGE)
{
//
// test merge code:
//
string_type s;
s = regex_merge(search_text, e, format_string.c_str(), flags[3]);
s = regex_merge(search_text, e, format_string.c_str(), static_cast<boost::match_flag_type>(flags[3]));
if(s != merge_string)
{
begin_error();
@@ -234,10 +244,15 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
if(recurse)
{
// copy and assign test:
reg_expression<C, T, A> e2(e);
basic_regex<C, T, A> e2(e);
cpp_tests(e2, false);
e2 = e;
cpp_tests(e2, false);
basic_regex<C, T, A> e3;
#ifndef BOOST_REGEX_V3
e3.swap(e2);
cpp_tests(e3, false);
#endif
}
if(e.error_code())
@@ -257,18 +272,18 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
debug_iterator<string_type::iterator> x(search_text.begin(), search_text.begin(), search_text.end());
debug_iterator<string_type::iterator> y(search_text.end(), search_text.begin(), search_text.end());
grep_test_predicate<debug_iterator<string_type::iterator>, allocator_type> oi(x, y);
regex_grep(oi, x, y, e, flags[3]);
regex_grep(oi, x, y, e, static_cast<boost::match_flag_type>(flags[3]));
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
if(!recurse)
{
unsigned len = search_text.size();
const std::basic_string<char_t>& s = search_text;
grep_test_predicate<std::basic_string<char_t>::const_iterator, allocator_type> oi2(s.begin(), s.end());
regex_grep(oi2, s, e, flags[3]);
regex_grep(oi2, s, e, static_cast<boost::match_flag_type>(flags[3]));
grep_test_predicate<const char_t*, allocator_type> oi3(s.c_str(), s.c_str()+s.size());
regex_grep(oi3, s.c_str(), e, flags[3]);
regex_grep(oi3, s.c_str(), e, static_cast<boost::match_flag_type>(flags[3]));
assert(s.size() == len);
assert(s.end() - s.begin() == len);
assert(s.end() - s.begin() == (std::basic_string<char_t>::difference_type)len);
}
#endif
}
@@ -278,8 +293,28 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
match_results< debug_iterator<string_type::iterator>, allocator_type> m;
debug_iterator<string_type::iterator> x(search_text.begin(), search_text.begin(), search_text.end());
debug_iterator<string_type::iterator> y(search_text.end(), search_text.begin(), search_text.end());
if(regex_search(x, y, m, e, flags[3]))
if(regex_search(x, y, m, e, static_cast<boost::match_flag_type>(flags[3])))
{
// special case for partial matches:
if(flags[4] & REG_PARTIAL_MATCH)
{
if(m[0].matched)
{
begin_error();
cout << "regex++ API result mismatch, found full match when partial match was expected: found ("
<< (m[0].first - x) << "," <<
(m[0].second - x) << ")" << endl;
}
else if(((m[0].first - x) != matches[0]) || ((m[0].second - x) != matches[1]))
{
begin_error();
cout << "regex++ API result mismatch in sub-expression " << 0 <<
", found (" << (m[0].first - x) << "," <<
(m[0].second - x) << ") expected (" <<
matches[0] << "," << matches[1] << ")" << endl;
}
return; // don't bother testing anything else for partial matches
}
// match found compare what matched with what we expect:
int j = 0;
for(unsigned int i = 0; i < m.size(); ++i, j += 2)
@@ -321,6 +356,24 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
(m[-2].first - x) << "," << (m[-2].second - x) << ") expected (" <<
matches[1] << "," << (y-x) << ")" << endl;
}
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)) && !defined(BOOST_REGEX_V3)
//
// now try comparison operators:
string_type s(m[0]);
if((s != m[0]) || (m[0] != s))
{
begin_error();
cout << "string comparison failed for result" << std::endl;
}
if(s.find_first_of((string_type::value_type)0) == string_type::npos)
{
if((m[0] != s.c_str()) || (s.c_str() != m[0]))
{
begin_error();
cout << "string comparison failed for result" << std::endl;
}
}
#endif
//
// now try alternative forms of regex_search if available:
@@ -329,18 +382,18 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
{
std::basic_string<char_t> s(search_text.begin(), search_text.end());
match_results<std::basic_string<char_t>::const_iterator> sm;
if(regex_search(s, sm, e, flags[3]))
if(regex_search(s, sm, e, static_cast<boost::match_flag_type>(flags[3])))
{
if(compare_result(sm, m) == false)
{
begin_error();
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const basic_regex&, int)" << endl;
}
}
else
{
begin_error();
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const basic_regex&, int)" << endl;
}
//
// partial match should give same result as full match
@@ -348,7 +401,7 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
//
if(matches[0] > 0)
{
if(regex_search(x, y, m, e, flags[3] | boost::match_partial))
if(regex_search(x, y, m, e, static_cast<boost::match_flag_type>(flags[3]) | boost::match_partial))
{
if(compare_result(sm, m) == false)
{
@@ -365,18 +418,18 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
if(s.find(char_t(0)) == std::basic_string<char_t>::npos)
{
match_results<const char_t*> ssm;
if(regex_search(search_text.c_str(), ssm, e, flags[3]))
if(regex_search(search_text.c_str(), ssm, e, static_cast<boost::match_flag_type>(flags[3])))
{
if(compare_result(ssm, m) == false)
{
begin_error();
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const basic_regex&, int)" << endl;
}
}
else
{
begin_error();
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const basic_regex&, int)" << endl;
}
}
}
@@ -389,49 +442,49 @@ void cpp_tests(const reg_expression<C, T, A>& e, bool recurse = true)
match_results< debug_iterator<string_type::iterator>, allocator_type> m1;
debug_iterator<string_type::iterator> x1(search_text.begin(), search_text.begin(), search_text.end());
debug_iterator<string_type::iterator> y1(search_text.end(), search_text.begin(), search_text.end());
if(regex_match(x1, y1, m1, e, flags[3]))
if(regex_match(x1, y1, m1, e, static_cast<boost::match_flag_type>(flags[3])))
{
if(compare_result(m1, m) == false)
{
begin_error();
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const basic_regex&, int)" << endl;
}
}
else
{
begin_error();
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_match(iterator, iterator, match_results&, const basic_regex&, int)" << endl;
}
std::basic_string<char_t> s(search_text.begin(), search_text.end());
match_results<std::basic_string<char_t>::const_iterator> sm;
if(regex_match(s, sm, e, flags[3]))
if(regex_match(s, sm, e, static_cast<boost::match_flag_type>(flags[3])))
{
if(compare_result(sm, m) == false)
{
begin_error();
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const basic_regex&, int)" << endl;
}
}
else
{
begin_error();
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_match(const std::string&, match_results&, const basic_regex&, int)" << endl;
}
if(s.find(char_t(0)) == std::basic_string<char_t>::npos)
{
match_results<const char_t*> ssm;
if(regex_match(search_text.c_str(), ssm, e, flags[3]))
if(regex_match(search_text.c_str(), ssm, e, static_cast<boost::match_flag_type>(flags[3])))
{
if(compare_result(ssm, m) == false)
{
begin_error();
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const basic_regex&, int)" << endl;
}
}
else
{
begin_error();
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const reg_expression&, int)" << endl;
cout << "regex++ API result mismatch in regex_match(const char_t*, match_results&, const basic_regex&, int)" << endl;
}
}
}
@@ -568,11 +621,11 @@ void cpp_hl_tests(RegEx& e, bool recurse = true)
// try to do grep:
hl_match_id = 0;
GrepCallback cb = hl_grep_test_proc;
e.Grep(cb, search_text.c_str(), flags[3]);
e.Grep(cb, search_text.c_str(), static_cast<boost::match_flag_type>(flags[3]));
}
else
{
if(e.Search(search_text.c_str(), flags[3]))
if(e.Search(search_text.c_str(), static_cast<boost::match_flag_type>(flags[3])))
{
unsigned int i = 0;
unsigned int j = 0;
@@ -600,9 +653,9 @@ void cpp_hl_tests(RegEx& e, bool recurse = true)
//
// test RegEx::Match only if we expect to match all of the input:
//
if((matches[0] == 0) && (matches[1] == search_text.size()))
if((matches[0] == 0) && (matches[1] == (int)search_text.size()))
{
if(e.Match(search_text.c_str(), flags[3]))
if(e.Match(search_text.c_str(), static_cast<boost::match_flag_type>(flags[3])))
{
unsigned int i = 0;
unsigned int j = 0;
+216 -13
View File
@@ -293,7 +293,7 @@ ab$ abxx -1 -1
ab$ ab\nzz 0 2
; back references
- match_default normal REG_EXTENDED
- match_default normal REG_PERL
a(b)\2c !
a(b\1)c !
a(b*)c\1d abbcbbd 0 7 1 3
@@ -307,7 +307,8 @@ a(([bc])\2)*d abbccd 0 6 3 5 3 4
a(([bc])\2)*d abbcbd -1 -1
a((b)*\2)*d abbbd 0 5 1 4 2 3
(ab*)[ab]*\1 ababaaa 0 7 0 1
; perl only:
(ab*)[ab]*\1 ababaaa 0 4 0 2
(a)\1bcd aabcd 0 5 0 1
(a)\1bc*d aabcd 0 5 0 1
(a)\1bc*d aabd 0 4 0 1
@@ -315,9 +316,13 @@ a((b)*\2)*d abbbd 0 5 1 4 2 3
(a)\1bc*[ce]d aabcccd 0 7 0 1
^(a)\1b(c)*cd$ aabcccd 0 7 0 1 4 5
; posix only:
- match_default extended REG_EXTENDED
(ab*)[ab]*\1 ababaaa 0 7 0 1
;
; characters by code:
- match_default normal REG_EXTENDED REG_STARTEND
- match_default normal REG_PERL REG_STARTEND
\0101 A 0 1
\00 \0 0 1
\0 \0 0 1
@@ -443,6 +448,7 @@ a(bbb+|bb+|b)b abbb 0 4 1 3
a(bbb+|bb+|b)bb abbb 0 4 1 2
(.*).* abcdef 0 6 0 6
(a*)* bc 0 0 0 0
xyx*xz xyxxxxyxxxz 5 11
; do we get the right subexpression when it is used more than once?
a(b|c)*d ad 0 2 -1 -1
@@ -450,7 +456,6 @@ a(b|c)*d abcd 0 4 2 3
a(b|c)+d abd 0 3 1 2
a(b|c)+d abcd 0 4 2 3
a(b|c?)+d ad 0 2 1 1
a(b|c?)+d abcd 0 4 2 3
a(b|c){0,0}d ad 0 2 -1 -1
a(b|c){0,1}d ad 0 2 -1 -1
a(b|c){0,1}d abd 0 3 1 2
@@ -470,13 +475,23 @@ a(b|c){2,4}d abcbd 0 5 3 4
a(b|c){2,4}d abcbcd 0 6 4 5
a(b|c){2,}d abcd 0 4 2 3
a(b|c){2,}d abcbd 0 5 3 4
; perl only:
a(b|c?)+d abcd 0 4 3 3
a(b+|((c)*))+d abd 0 3 2 2 2 2 -1 -1
a(b+|((c)*))+d abcd 0 4 3 3 3 3 2 3
; posix only:
- match_default extended REG_EXTENDED REG_STARTEND
a(b|c?)+d abcd 0 4 2 3
a(b|((c)*))+d abcd 0 4 2 3 2 3 2 3
a(b+|((c)*))+d abd 0 3 1 2 -1 -1 -1 -1
a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
- match_default normal REG_EXTENDED REG_STARTEND REG_NOSPEC literal
\**?/{} \\**?/{} 0 7
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST ; we disable POSIX testing because it can't handle escapes in sets
- match_default normal REG_PERL
; try to match C++ syntax elements:
; line comment:
//[^\n]* "++i //here is a line comment\n" 4 28
@@ -490,7 +505,8 @@ a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
; preprossor directives:
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol" 0 19 -1 -1
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) #x" 0 25 -1 -1
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 28 42
; perl only:
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 30 42
; literals:
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFF 0 4 0 4 0 4 -1 -1 -1 -1 -1 -1 -1 -1
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 35 0 2 0 2 -1 -1 0 2 -1 -1 -1 -1 -1 -1
@@ -502,6 +518,11 @@ a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
'([^\\']|\\.)*' '\\'' 0 4 1 3
'([^\\']|\\.)*' '\\n' 0 4 1 3
; posix only:
- match_default extended escape_in_lists REG_EXTENDED REG_NO_POSIX_TEST ; we disable POSIX testing because it can't handle escapes in sets
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 28 42
; now try and test some unicode specific characters:
- match_default normal REG_PERL REG_UNICODE_ONLY
[[:unicode:]]+ a\0300\0400z 1 3
@@ -837,7 +858,7 @@ a+(b+) "...aaabb,,,ab*abbb?" $1 "...bb,,,ab*abbb?"
;
; non-greedy repeats added 21/04/00
- match_default normal REG_EXTENDED
- match_default normal REG_EXTENDED REG_PERL
a** !
a*? aa 0 0
a?? aa 0 0
@@ -854,7 +875,7 @@ abc|\w+? abcd 0 3
;
; non-marking parenthesis added 25/04/00
- match_default normal REG_EXTENDED
- match_default normal REG_EXTENDED REG_PERL
(?:abc)+ xxabcabcxx 2 8
(?:a+)(b+) xaaabbbx 1 7 4 7
(a+)(?:b+) xaaabbba 1 7 1 4
@@ -867,14 +888,19 @@ a+(?#b+)b+ xaaabbba 1 7
;
; try some partial matches:
- match_partial match_default normal REG_EXTENDED REG_NO_POSIX_TEST
(xyz)(.*)abc xyzaaab -1 -1 0 3 3 7
(xyz)(.*)abc xyz -1 -1 0 3 3 3
(xyz)(.*)abc xy -1 -1 -1 -1 -1 -1
- match_partial match_default normal REG_EXTENDED REG_NO_POSIX_TEST REG_PARTIAL_MATCH REG_PERL
(xyz)(.*)abc xyzaaab 0 7
(xyz)(.*)abc xyz 0 3
(xyz)(.*)abc xy 0 2
(xyz)(.*)abc x 0 1
(xyz)(.*)abc "" -1 -1
(xyz)(.*)abc aaaa -1 -1
.abc aaab 1 4
a[_] xxa 2 3
;
; forward lookahead asserts added 21/01/02
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST REG_PERL
((?:(?!a|b)\w)+)(\w+) " xxxabaxxx " 2 11 2 5 5 11
/\*(?:(?!\*/).)*\*/ " /**/ " 2 6
@@ -902,6 +928,183 @@ a+(?#b+)b+ xaaabbba 1 7
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ abC3 0 4
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ ABCD3 -1 -1
; extended repeat checking to exercise new algorithms:
ab.*xy abxy_ 0 4
ab.*xy ab_xy_ 0 5
ab.*xy abxy 0 4
ab.*xy ab_xy 0 5
ab.* ab 0 2
ab.* ab__ 0 4
ab.{2,5}xy ab__xy_ 0 6
ab.{2,5}xy ab____xy_ 0 8
ab.{2,5}xy ab_____xy_ 0 9
ab.{2,5}xy ab__xy 0 6
ab.{2,5}xy ab_____xy 0 9
ab.{2,5} ab__ 0 4
ab.{2,5} ab_______ 0 7
ab.{2,5}xy ab______xy -1 -1
ab.{2,5}xy ab_xy -1 -1
ab.*?xy abxy_ 0 4
ab.*?xy ab_xy_ 0 5
ab.*?xy abxy 0 4
ab.*?xy ab_xy 0 5
ab.*? ab 0 2
ab.*? ab__ 0 2
ab.{2,5}?xy ab__xy_ 0 6
ab.{2,5}?xy ab____xy_ 0 8
ab.{2,5}?xy ab_____xy_ 0 9
ab.{2,5}?xy ab__xy 0 6
ab.{2,5}?xy ab_____xy 0 9
ab.{2,5}? ab__ 0 4
ab.{2,5}? ab_______ 0 4
ab.{2,5}?xy ab______xy -1 -1
ab.{2,5}xy ab_xy -1 -1
; again but with slower algorithm variant:
- match_default normal REG_PERL REG_NO_POSIX_TEST match_not_dot_newline match_not_dot_null
ab.*xy abxy_ 0 4
ab.*xy ab_xy_ 0 5
ab.*xy abxy 0 4
ab.*xy ab_xy 0 5
ab.* ab 0 2
ab.* ab__ 0 4
ab.{2,5}xy ab__xy_ 0 6
ab.{2,5}xy ab____xy_ 0 8
ab.{2,5}xy ab_____xy_ 0 9
ab.{2,5}xy ab__xy 0 6
ab.{2,5}xy ab_____xy 0 9
ab.{2,5} ab__ 0 4
ab.{2,5} ab_______ 0 7
ab.{2,5}xy ab______xy -1 -1
ab.{2,5}xy ab_xy -1 -1
ab.*?xy abxy_ 0 4
ab.*?xy ab_xy_ 0 5
ab.*?xy abxy 0 4
ab.*?xy ab_xy 0 5
ab.*? ab 0 2
ab.*? ab__ 0 2
ab.{2,5}?xy ab__xy_ 0 6
ab.{2,5}?xy ab____xy_ 0 8
ab.{2,5}?xy ab_____xy_ 0 9
ab.{2,5}?xy ab__xy 0 6
ab.{2,5}?xy ab_____xy 0 9
ab.{2,5}? ab__ 0 4
ab.{2,5}? ab_______ 0 4
ab.{2,5}?xy ab______xy -1 -1
ab.{2,5}xy ab_xy -1 -1
; now again for single character repeats:
ab_*xy abxy_ 0 4
ab_*xy ab_xy_ 0 5
ab_*xy abxy 0 4
ab_*xy ab_xy 0 5
ab_* ab 0 2
ab_* ab__ 0 4
ab_{2,5}xy ab__xy_ 0 6
ab_{2,5}xy ab____xy_ 0 8
ab_{2,5}xy ab_____xy_ 0 9
ab_{2,5}xy ab__xy 0 6
ab_{2,5}xy ab_____xy 0 9
ab_{2,5} ab__ 0 4
ab_{2,5} ab_______ 0 7
ab_{2,5}xy ab______xy -1 -1
ab_{2,5}xy ab_xy -1 -1
ab_*?xy abxy_ 0 4
ab_*?xy ab_xy_ 0 5
ab_*?xy abxy 0 4
ab_*?xy ab_xy 0 5
ab_*? ab 0 2
ab_*? ab__ 0 2
ab_{2,5}?xy ab__xy_ 0 6
ab_{2,5}?xy ab____xy_ 0 8
ab_{2,5}?xy ab_____xy_ 0 9
ab_{2,5}?xy ab__xy 0 6
ab_{2,5}?xy ab_____xy 0 9
ab_{2,5}? ab__ 0 4
ab_{2,5}? ab_______ 0 4
ab_{2,5}?xy ab______xy -1 -1
ab_{2,5}xy ab_xy -1 -1
; and again for sets:
ab[_,;]*xy abxy_ 0 4
ab[_,;]*xy ab_xy_ 0 5
ab[_,;]*xy abxy 0 4
ab[_,;]*xy ab_xy 0 5
ab[_,;]* ab 0 2
ab[_,;]* ab__ 0 4
ab[_,;]{2,5}xy ab__xy_ 0 6
ab[_,;]{2,5}xy ab____xy_ 0 8
ab[_,;]{2,5}xy ab_____xy_ 0 9
ab[_,;]{2,5}xy ab__xy 0 6
ab[_,;]{2,5}xy ab_____xy 0 9
ab[_,;]{2,5} ab__ 0 4
ab[_,;]{2,5} ab_______ 0 7
ab[_,;]{2,5}xy ab______xy -1 -1
ab[_,;]{2,5}xy ab_xy -1 -1
ab[_,;]*?xy abxy_ 0 4
ab[_,;]*?xy ab_xy_ 0 5
ab[_,;]*?xy abxy 0 4
ab[_,;]*?xy ab_xy 0 5
ab[_,;]*? ab 0 2
ab[_,;]*? ab__ 0 2
ab[_,;]{2,5}?xy ab__xy_ 0 6
ab[_,;]{2,5}?xy ab____xy_ 0 8
ab[_,;]{2,5}?xy ab_____xy_ 0 9
ab[_,;]{2,5}?xy ab__xy 0 6
ab[_,;]{2,5}?xy ab_____xy 0 9
ab[_,;]{2,5}? ab__ 0 4
ab[_,;]{2,5}? ab_______ 0 4
ab[_,;]{2,5}?xy ab______xy -1 -1
ab[_,;]{2,5}xy ab_xy -1 -1
; and again for tricky sets with digraphs:
ab[_[.ae.]]*xy abxy_ 0 4
ab[_[.ae.]]*xy ab_xy_ 0 5
ab[_[.ae.]]*xy abxy 0 4
ab[_[.ae.]]*xy ab_xy 0 5
ab[_[.ae.]]* ab 0 2
ab[_[.ae.]]* ab__ 0 4
ab[_[.ae.]]{2,5}xy ab__xy_ 0 6
ab[_[.ae.]]{2,5}xy ab____xy_ 0 8
ab[_[.ae.]]{2,5}xy ab_____xy_ 0 9
ab[_[.ae.]]{2,5}xy ab__xy 0 6
ab[_[.ae.]]{2,5}xy ab_____xy 0 9
ab[_[.ae.]]{2,5} ab__ 0 4
ab[_[.ae.]]{2,5} ab_______ 0 7
ab[_[.ae.]]{2,5}xy ab______xy -1 -1
ab[_[.ae.]]{2,5}xy ab_xy -1 -1
ab[_[.ae.]]*?xy abxy_ 0 4
ab[_[.ae.]]*?xy ab_xy_ 0 5
ab[_[.ae.]]*?xy abxy 0 4
ab[_[.ae.]]*?xy ab_xy 0 5
ab[_[.ae.]]*? ab 0 2
ab[_[.ae.]]*? ab__ 0 2
ab[_[.ae.]]{2,5}?xy ab__xy_ 0 6
ab[_[.ae.]]{2,5}?xy ab____xy_ 0 8
ab[_[.ae.]]{2,5}?xy ab_____xy_ 0 9
ab[_[.ae.]]{2,5}?xy ab__xy 0 6
ab[_[.ae.]]{2,5}?xy ab_____xy 0 9
ab[_[.ae.]]{2,5}? ab__ 0 4
ab[_[.ae.]]{2,5}? ab_______ 0 4
ab[_[.ae.]]{2,5}?xy ab______xy -1 -1
ab[_[.ae.]]{2,5}xy ab_xy -1 -1
; new bugs detected in spring 2003:
- normal match_continuous REG_NO_POSIX_TEST
b abc -1 -1
+908
View File
@@ -0,0 +1,908 @@
;
;
; this file contains a script of tests to run through regress.exe
;
; comments start with a semicolon and proceed to the end of the line
;
; changes to regular expression compile flags start with a "-" as the first
; non-whitespace character and consist of a list of the printable names
; of the flags, for example "match_default"
;
; Other lines contain a test to perform using the current flag status
; the first token contains the expression to compile, the second the string
; to match it against. If the second string is "!" then the expression should
; not compile, that is the first string is an invalid regular expression.
; This is then followed by a list of integers that specify what should match,
; each pair represents the starting and ending positions of a subexpression
; starting with the zeroth subexpression (the whole match).
; A value of -1 indicates that the subexpression should not take part in the
; match at all, if the first value is -1 then no part of the expression should
; match the string.
;
- match_default normal REG_EXTENDED
;
; try some really simple literals:
a a 0 1
Z Z 0 1
Z aaa -1 -1
Z xxxxZZxxx 4 5
; and some simple brackets:
(a) zzzaazz 3 4 3 4
() zzz 0 0 0 0
() "" 0 0 0 0
( !
) !
(aa !
aa) !
a b -1 -1
\(\) () 0 2
\(a\) (a) 0 3
\() !
(\) !
p(a)rameter ABCparameterXYZ 3 12 4 5
[pq](a)rameter ABCparameterXYZ 3 12 4 5
; now try escaped brackets:
- match_default bk_parens REG_BASIC
\(a\) zzzaazz 3 4 3 4
\(\) zzz 0 0 0 0
\(\) "" 0 0 0 0
\( !
\) !
\(aa !
aa\) !
() () 0 2
(a) (a) 0 3
(\) !
\() !
; now move on to "." wildcards
- match_default normal REG_EXTENDED REG_STARTEND
. a 0 1
. \n 0 1
. \r 0 1
. \0 0 1
- match_default normal match_not_dot_newline REG_EXTENDED REG_STARTEND REG_NEWLINE
. a 0 1
. \n -1 -1
. \r -1 -1
. \0 0 1
- match_default normal match_not_dot_null match_not_dot_newline REG_EXTENDED REG_STARTEND REG_NEWLINE
. \n -1 -1
. \r -1 -1
; this *WILL* produce an error from the POSIX API functions:
- match_default normal match_not_dot_null match_not_dot_newline REG_EXTENDED REG_STARTEND REG_NEWLINE REG_NO_POSIX_TEST
. \0 -1 -1
;
; now move on to the repetion ops,
; starting with operator *
- match_default normal REG_EXTENDED
a* b 0 0
ab* a 0 1
ab* ab 0 2
ab* sssabbbbbbsss 3 10
ab*c* a 0 1
ab*c* abbb 0 4
ab*c* accc 0 4
ab*c* abbcc 0 5
*a !
\<* !
\>* !
\n* \n\n 0 2
\** ** 0 2
\* * 0 1
; now try operator +
ab+ a -1 -1
ab+ ab 0 2
ab+ sssabbbbbbsss 3 10
ab+c+ a -1 -1
ab+c+ abbb -1 -1
ab+c+ accc -1 -1
ab+c+ abbcc 0 5
+a !
\<+ !
\>+ !
\n+ \n\n 0 2
\+ + 0 1
\+ ++ 0 1
\++ ++ 0 2
- match_default normal bk_plus_qm REG_EXTENDED REG_NO_POSIX_TEST
+ + 0 1
\+ !
a\+ aa 0 2
; now try operator ?
- match_default normal REG_EXTENDED
a? b 0 0
ab? a 0 1
ab? ab 0 2
ab? sssabbbbbbsss 3 5
ab?c? a 0 1
ab?c? abbb 0 2
ab?c? accc 0 2
ab?c? abcc 0 3
?a !
\<? !
\>? !
\n? \n\n 0 1
\? ? 0 1
\? ?? 0 1
\?? ?? 0 1
- match_default normal bk_plus_qm REG_EXTENDED REG_NO_POSIX_TEST
? ? 0 1
\? !
a\? aa 0 1
a\? b 0 0
- match_default normal limited_ops
a? a? 0 2
a+ a+ 0 2
a\? a? 0 2
a\+ a+ 0 2
; now try operator {}
- match_default normal REG_EXTENDED
a{2} a -1 -1
a{2} aa 0 2
a{2} aaa 0 2
a{2,} a -1 -1
a{2,} aa 0 2
a{2,} aaaaa 0 5
a{2,4} a -1 -1
a{2,4} aa 0 2
a{2,4} aaa 0 3
a{2,4} aaaa 0 4
a{2,4} aaaaa 0 4
; spaces are now allowed inside {}
"a{ 2 , 4 }" aaaaa 0 4
a{} !
"a{ }" !
a{2 !
a} !
\{\} {} 0 2
- match_default normal bk_braces
a\{2\} a -1 -1
a\{2\} aa 0 2
a\{2\} aaa 0 2
a\{2,\} a -1 -1
a\{2,\} aa 0 2
a\{2,\} aaaaa 0 5
a\{2,4\} a -1 -1
a\{2,4\} aa 0 2
a\{2,4\} aaa 0 3
a\{2,4\} aaaa 0 4
a\{2,4\} aaaaa 0 4
"a\{ 2 , 4 \}" aaaaa 0 4
{} {} 0 2
; now test the alternation operator |
- match_default normal REG_EXTENDED
a|b a 0 1
a|b b 0 1
a(b|c) ab 0 2 1 2
a(b|c) ac 0 2 1 2
a(b|c) ad -1 -1 -1 -1
|c !
c| !
(|) !
(a|) !
(|a) !
a\| a| 0 2
- match_default normal limited_ops
a| a| 0 2
a\| a| 0 2
| | 0 1
- match_default normal bk_vbar REG_NO_POSIX_TEST
a| a| 0 2
a\|b a 0 1
a\|b b 0 1
; now test the set operator []
- match_default normal REG_EXTENDED
; try some literals first
[abc] a 0 1
[abc] b 0 1
[abc] c 0 1
[abc] d -1 -1
[^bcd] a 0 1
[^bcd] b -1 -1
[^bcd] d -1 -1
[^bcd] e 0 1
a[b]c abc 0 3
a[ab]c abc 0 3
a[^ab]c adc 0 3
a[]b]c a]c 0 3
a[[b]c a[c 0 3
a[-b]c a-c 0 3
a[^]b]c adc 0 3
a[^-b]c adc 0 3
a[b-]c a-c 0 3
a[b !
a[] !
; then some ranges
[b-e] a -1 -1
[b-e] b 0 1
[b-e] e 0 1
[b-e] f -1 -1
[^b-e] a 0 1
[^b-e] b -1 -1
[^b-e] e -1 -1
[^b-e] f 0 1
a[1-3]c a2c 0 3
a[3-1]c !
a[1-3-5]c !
a[1- !
; and some classes
a[[:alpha:]]c abc 0 3
a[[:unknown:]]c !
a[[: !
a[[:alpha !
a[[:alpha:] !
a[[:alpha,:] !
a[[:]:]]b !
a[[:-:]]b !
a[[:alph:]] !
a[[:alphabet:]] !
[[:alnum:]]+ -%@a0X_- 3 6
[[:alpha:]]+ -%@aX_0- 3 5
[[:blank:]]+ "a \tb" 1 4
[[:cntrl:]]+ a\n\tb 1 3
[[:digit:]]+ a019b 1 4
[[:graph:]]+ " a%b " 1 4
[[:lower:]]+ AabC 1 3
; This test fails with STLPort, disable for now as this is a corner case anyway...
;[[:print:]]+ "\na b\n" 1 4
[[:punct:]]+ " %-&\t" 1 4
[[:space:]]+ "a \n\t\rb" 1 5
[[:upper:]]+ aBCd 1 3
[[:xdigit:]]+ p0f3Cx 1 5
; now test flag settings:
- escape_in_lists REG_NO_POSIX_TEST
[\n] \n 0 1
- REG_NO_POSIX_TEST
[\n] \n -1 -1
[\n] \\ 0 1
[[:class:] : 0 1
[[:class:] [ 0 1
[[:class:] c 0 1
; line anchors
- match_default normal REG_EXTENDED
^ab ab 0 2
^ab xxabxx -1 -1
^ab xx\nabzz 3 5
ab$ ab 0 2
ab$ abxx -1 -1
ab$ ab\nzz 0 2
- match_default match_not_bol match_not_eol normal REG_EXTENDED REG_NOTBOL REG_NOTEOL
^ab ab -1 -1
^ab xxabxx -1 -1
^ab xx\nabzz 3 5
ab$ ab -1 -1
ab$ abxx -1 -1
ab$ ab\nzz 0 2
; back references
- match_default normal REG_EXTENDED
a(b)\2c !
a(b\1)c !
a(b*)c\1d abbcbbd 0 7 1 3
a(b*)c\1d abbcbd -1 -1
a(b*)c\1d abbcbbbd -1 -1
^(.)\1 abc -1 -1
a([bc])\1d abcdabbd 4 8 5 6
; strictly speaking this is at best ambiguous, at worst wrong, this is what most
; re implimentations will match though.
a(([bc])\2)*d abbccd 0 6 3 5 3 4
a(([bc])\2)*d abbcbd -1 -1
a((b)*\2)*d abbbd 0 5 1 4 2 3
(ab*)[ab]*\1 ababaaa 0 7 0 1
(a)\1bcd aabcd 0 5 0 1
(a)\1bc*d aabcd 0 5 0 1
(a)\1bc*d aabd 0 4 0 1
(a)\1bc*d aabcccd 0 7 0 1
(a)\1bc*[ce]d aabcccd 0 7 0 1
^(a)\1b(c)*cd$ aabcccd 0 7 0 1 4 5
;
; characters by code:
- match_default normal REG_EXTENDED REG_STARTEND
\0101 A 0 1
\00 \0 0 1
\0 \0 0 1
\0172 z 0 1
;
; word operators:
\w a 0 1
\w z 0 1
\w A 0 1
\w Z 0 1
\w _ 0 1
\w } -1 -1
\w ` -1 -1
\w [ -1 -1
\w @ -1 -1
; non-word:
\W a -1 -1
\W z -1 -1
\W A -1 -1
\W Z -1 -1
\W _ -1 -1
\W } 0 1
\W ` 0 1
\W [ 0 1
\W @ 0 1
; word start:
\<abcd " abcd" 2 6
\<ab cab -1 -1
\<ab "\nab" 1 3
\<tag ::tag 2 5
;word end:
abc\> abc 0 3
abc\> abcd -1 -1
abc\> abc\n 0 3
abc\> abc:: 0 3
; word boundary:
\babcd " abcd" 2 6
\bab cab -1 -1
\bab "\nab" 1 3
\btag ::tag 2 5
abc\b abc 0 3
abc\b abcd -1 -1
abc\b abc\n 0 3
abc\b abc:: 0 3
; within word:
\B ab 1 1
a\Bb ab 0 2
a\B ab 0 1
a\B a -1 -1
a\B "a " -1 -1
;
; buffer operators:
\`abc abc 0 3
\`abc \nabc -1 -1
\`abc " abc" -1 -1
abc\' abc 0 3
abc\' abc\n -1 -1
abc\' "abc " -1 -1
;
; extra escape sequences:
\a \a 0 1
\f \f 0 1
\n \n 0 1
\r \r 0 1
\t \t 0 1
\v \v 0 1
;
; now follows various complex expressions designed to try and bust the matcher:
a(((b)))c abc 0 3 1 2 1 2 1 2
a(b|(c))d abd 0 3 1 2 -1 -1
a(b|(c))d acd 0 3 1 2 1 2
a(b*|c)d abbd 0 4 1 3
; just gotta have one DFA-buster, of course
a[ab]{20} aaaaabaaaabaaaabaaaab 0 21
; and an inline expansion in case somebody gets tricky
a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] aaaaabaaaabaaaabaaaab 0 21
; and in case somebody just slips in an NFA...
a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) aaaaabaaaabaaaabaaaabweeknights 0 31 21 24 24 31
; one really big one
1234567890123456789012345678901234567890123456789012345678901234567890 a1234567890123456789012345678901234567890123456789012345678901234567890b 1 71
; fish for problems as brackets go past 8
[ab][cd][ef][gh][ij][kl][mn] xacegikmoq 1 8
[ab][cd][ef][gh][ij][kl][mn][op] xacegikmoq 1 9
[ab][cd][ef][gh][ij][kl][mn][op][qr] xacegikmoqy 1 10
[ab][cd][ef][gh][ij][kl][mn][op][q] xacegikmoqy 1 10
; and as parenthesis go past 9:
(a)(b)(c)(d)(e)(f)(g)(h) zabcdefghi 1 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9
(a)(b)(c)(d)(e)(f)(g)(h)(i) zabcdefghij 1 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j) zabcdefghijk 1 11 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k) zabcdefghijkl 1 12 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12
(a)d|(b)c abc 1 3 -1 -1 1 2
"_+((www)|(ftp)|(mailto)):_*" "_wwwnocolon _mailto:" 12 20 13 19 -1 -1 -1 -1 13 19
; subtleties of matching
a(b)?c\1d acd 0 3 -1 -1
a(b?c)+d accd 0 4 2 3
(wee|week)(knights|night) weeknights 0 10 0 3 3 10
.* abc 0 3
a(b|(c))d abd 0 3 1 2 -1 -1
a(b|(c))d acd 0 3 1 2 1 2
a(b*|c|e)d abbd 0 4 1 3
a(b*|c|e)d acd 0 3 1 2
a(b*|c|e)d ad 0 2 1 1
a(b?)c abc 0 3 1 2
a(b?)c ac 0 2 1 1
a(b+)c abc 0 3 1 2
a(b+)c abbbc 0 5 1 4
a(b*)c ac 0 2 1 1
(a|ab)(bc([de]+)f|cde) abcdef 0 6 0 1 1 6 3 5
a([bc]?)c abc 0 3 1 2
a([bc]?)c ac 0 2 1 1
a([bc]+)c abc 0 3 1 2
a([bc]+)c abcc 0 4 1 3
a([bc]+)bc abcbc 0 5 1 3
a(bb+|b)b abb 0 3 1 2
a(bbb+|bb+|b)b abb 0 3 1 2
a(bbb+|bb+|b)b abbb 0 4 1 3
a(bbb+|bb+|b)bb abbb 0 4 1 2
(.*).* abcdef 0 6 0 6
(a*)* bc 0 0 0 0
; do we get the right subexpression when it is used more than once?
a(b|c)*d ad 0 2 -1 -1
a(b|c)*d abcd 0 4 2 3
a(b|c)+d abd 0 3 1 2
a(b|c)+d abcd 0 4 2 3
a(b|c?)+d ad 0 2 1 1
a(b|c?)+d abcd 0 4 2 3
a(b|c){0,0}d ad 0 2 -1 -1
a(b|c){0,1}d ad 0 2 -1 -1
a(b|c){0,1}d abd 0 3 1 2
a(b|c){0,2}d ad 0 2 -1 -1
a(b|c){0,2}d abcd 0 4 2 3
a(b|c){0,}d ad 0 2 -1 -1
a(b|c){0,}d abcd 0 4 2 3
a(b|c){1,1}d abd 0 3 1 2
a(b|c){1,2}d abd 0 3 1 2
a(b|c){1,2}d abcd 0 4 2 3
a(b|c){1,}d abd 0 3 1 2
a(b|c){1,}d abcd 0 4 2 3
a(b|c){2,2}d acbd 0 4 2 3
a(b|c){2,2}d abcd 0 4 2 3
a(b|c){2,4}d abcd 0 4 2 3
a(b|c){2,4}d abcbd 0 5 3 4
a(b|c){2,4}d abcbcd 0 6 4 5
a(b|c){2,}d abcd 0 4 2 3
a(b|c){2,}d abcbd 0 5 3 4
a(b+|((c)*))+d abd 0 3 1 2 -1 -1 -1 -1
a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
- match_default normal REG_EXTENDED REG_STARTEND REG_NOSPEC literal
\**?/{} \\**?/{} 0 7
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST ; we disable POSIX testing because it can't handle escapes in sets
; try to match C++ syntax elements:
; line comment:
//[^\n]* "++i //here is a line comment\n" 4 28
; block comment:
/\*([^*]|\*+[^*/])*\*+/ "/* here is a block comment */" 0 29 26 27
/\*([^*]|\*+[^*/])*\*+/ "/**/" 0 4 -1 -1
/\*([^*]|\*+[^*/])*\*+/ "/***/" 0 5 -1 -1
/\*([^*]|\*+[^*/])*\*+/ "/****/" 0 6 -1 -1
/\*([^*]|\*+[^*/])*\*+/ "/*****/" 0 7 -1 -1
/\*([^*]|\*+[^*/])*\*+/ "/*****/*/" 0 7 -1 -1
; preprossor directives:
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol" 0 19 -1 -1
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) #x" 0 25 -1 -1
^[[:blank:]]*#([^\n]*\\[[:space:]]+)*[^\n]* "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);" 0 53 28 42
; literals:
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFF 0 4 0 4 0 4 -1 -1 -1 -1 -1 -1 -1 -1
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 35 0 2 0 2 -1 -1 0 2 -1 -1 -1 -1 -1 -1
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFu 0 5 0 4 0 4 -1 -1 -1 -1 -1 -1 -1 -1
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFL 0 5 0 4 0 4 -1 -1 4 5 -1 -1 -1 -1
((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)? 0xFFFFFFFFFFFFFFFFuint64 0 24 0 18 0 18 -1 -1 19 24 19 24 22 24
; strings:
'([^\\']|\\.)*' '\\x3A' 0 6 4 5
'([^\\']|\\.)*' '\\'' 0 4 1 3
'([^\\']|\\.)*' '\\n' 0 4 1 3
; now try and test some unicode specific characters:
- match_default normal REG_PERL REG_UNICODE_ONLY
[[:unicode:]]+ a\0300\0400z 1 3
[\x10-\xff] \39135\12409 -1 -1
[\01-\05]{5} \36865\36865\36865\36865\36865 -1 -1
; finally try some case insensitive matches:
- match_default normal REG_EXTENDED REG_ICASE
; upper and lower have no meaning here so they fail, however these
; may compile with other libraries...
;[[:lower:]] !
;[[:upper:]] !
0123456789@abcdefghijklmnopqrstuvwxyz\[\\\]\^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ\{\|\} 0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]\^_`abcdefghijklmnopqrstuvwxyz\{\|\} 0 72
; known and suspected bugs:
- match_default normal REG_EXTENDED
\( ( 0 1
\) ) 0 1
\$ $ 0 1
\^ ^ 0 1
\. . 0 1
\* * 0 1
\+ + 0 1
\? ? 0 1
\[ [ 0 1
\] ] 0 1
\| | 0 1
\\ \\ 0 1
# # 0 1
\# # 0 1
a- a- 0 2
\- - 0 1
\{ { 0 1
\} } 0 1
0 0 0 1
1 1 0 1
9 9 0 1
b b 0 1
B B 0 1
< < 0 1
> > 0 1
w w 0 1
W W 0 1
` ` 0 1
' ' 0 1
\n \n 0 1
, , 0 1
a a 0 1
f f 0 1
n n 0 1
r r 0 1
t t 0 1
v v 0 1
c c 0 1
x x 0 1
: : 0 1
(\.[[:alnum:]]+){2} "w.a.b " 1 5 3 5
- match_default normal REG_EXTENDED REG_ICASE
a A 0 1
A a 0 1
[abc]+ abcABC 0 6
[ABC]+ abcABC 0 6
[a-z]+ abcABC 0 6
[A-Z]+ abzANZ 0 6
[a-Z]+ abzABZ 0 6
[A-z]+ abzABZ 0 6
[[:lower:]]+ abyzABYZ 0 8
[[:upper:]]+ abzABZ 0 6
[[:word:]]+ abcZZZ 0 6
[[:alpha:]]+ abyzABYZ 0 8
[[:alnum:]]+ 09abyzABYZ 0 10
; updated tests for version 2:
- match_default normal REG_EXTENDED
\x41 A 0 1
\xff \255 0 1
\xFF \255 0 1
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST
\c@ \0 0 1
- match_default normal REG_EXTENDED
\cA \1 0 1
\cz \58 0 1
\c= !
\c? !
=: =: 0 2
; word start:
[[:<:]]abcd " abcd" 2 6
[[:<:]]ab cab -1 -1
[[:<:]]ab "\nab" 1 3
[[:<:]]tag ::tag 2 5
;word end:
abc[[:>:]] abc 0 3
abc[[:>:]] abcd -1 -1
abc[[:>:]] abc\n 0 3
abc[[:>:]] abc:: 0 3
; collating elements and rewritten set code:
- match_default normal REG_EXTENDED REG_STARTEND
[[.zero.]] 0 0 1
[[.one.]] 1 0 1
[[.two.]] 2 0 1
[[.three.]] 3 0 1
[[.a.]] baa 1 2
[[.right-curly-bracket.]] } 0 1
[[.NUL.]] \0 0 1
[[:<:]z] !
[a[:>:]] !
[[=a=]] a 0 1
[[=right-curly-bracket=]] } 0 1
- match_default normal REG_EXTENDED REG_STARTEND REG_ICASE
[[.A.]] A 0 1
[[.A.]] a 0 1
[[.A.]-b]+ AaBb 0 4
[A-[.b.]]+ AaBb 0 4
[[.a.]-B]+ AaBb 0 4
[a-[.B.]]+ AaBb 0 4
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST
[\x61] a 0 1
[\x61-c]+ abcd 0 3
[a-\x63]+ abcd 0 3
- match_default normal REG_EXTENDED REG_STARTEND
[[.a.]-c]+ abcd 0 3
[a-[.c.]]+ abcd 0 3
[[:alpha:]-a] !
[a-[:alpha:]] !
; try mutli-character ligatures:
[[.ae.]] ae 0 2
[[.ae.]] aE -1 -1
[[.AE.]] AE 0 2
[[.Ae.]] Ae 0 2
[[.ae.]-b] a -1 -1
[[.ae.]-b] b 0 1
[[.ae.]-b] ae 0 2
[a-[.ae.]] a 0 1
[a-[.ae.]] b -1 -1
[a-[.ae.]] ae 0 2
- match_default normal REG_EXTENDED REG_STARTEND REG_ICASE
[[.ae.]] AE 0 2
[[.ae.]] Ae 0 2
[[.AE.]] Ae 0 2
[[.Ae.]] aE 0 2
[[.AE.]-B] a -1 -1
[[.Ae.]-b] b 0 1
[[.Ae.]-b] B 0 1
[[.ae.]-b] AE 0 2
- match_default normal REG_EXTENDED REG_STARTEND
;extended perl style escape sequences:
\e \27 0 1
\x1b \27 0 1
\x{1b} \27 0 1
\x{} !
\x{ !
\x} !
\x !
\x{yy !
\x{1b !
- match_default normal REG_EXTENDED REG_STARTEND REG_NO_POSIX_TEST
\l+ ABabcAB 2 5
[\l]+ ABabcAB 2 5
[a-\l] !
[\l-a] !
[\L] !
\L+ abABCab 2 5
\u+ abABCab 2 5
[\u]+ abABCab 2 5
[\U] !
\U+ ABabcAB 2 5
\d+ ab012ab 2 5
[\d]+ ab012ab 2 5
[\D] !
\D+ 01abc01 2 5
\s+ "ab ab" 2 5
[\s]+ "ab ab" 2 5
[\S] !
\S+ " abc " 2 5
- match_default normal REG_EXTENDED REG_STARTEND
\Qabc !
\Qabc\E abcd 0 3
\Qabc\Ed abcde 0 4
\Q+*?\\E +*?\\ 0 4
\C+ abcde 0 5
\X+ abcde 0 5
- match_default normal REG_EXTENDED REG_STARTEND REG_UNICODE_ONLY
\X+ a\768\769 0 3
\X+ \2309\2307 0 2 ;DEVANAGARI script
\X+ \2489\2494 0 2 ;BENGALI script
- match_default normal REG_EXTENDED REG_STARTEND
\Aabc abc 0 3
\Aabc aabc -1 -1
abc\z abc 0 3
abc\z abcd -1 -1
abc\Z abc\n\n 0 3
abc\Z abc 0 3
\Gabc abc 0 3
\Gabc dabcd -1 -1
a\Gbc abc -1 -1
a\Aab abc -1 -1
;
; now test grep,
; basically check all our restart types - line, word, etc
; checking each one for null and non-null matches.
;
- match_default normal REG_EXTENDED REG_STARTEND REG_GREP
a " a a a aa" 1 2 3 4 5 6 7 8 8 9
a+b+ "aabaabbb ab" 0 3 3 8 9 11
a(b*|c|e)d adabbdacd 0 2 2 6 6 9
a "\na\na\na\naa" 1 2 3 4 5 6 7 8 8 9
^ " \n\n \n\n\n" 0 0 4 4 5 5 8 8 9 9 10 10
^ab "ab \nab ab\n" 0 2 5 7
^[^\n]*\n " \n \n\n \n" 0 4 4 7 7 8 8 11
\<abc "abcabc abc\n\nabc" 0 3 7 10 12 15
\< " ab a aaa " 2 2 5 5 7 7
\<\w+\W+ " aa aa a " 1 5 5 9 9 11
\Aabc "abc abc" 0 3
\G\w+\W+ "abc abc a cbbb " 0 5 5 9 9 11 11 18
\Ga+b+ "aaababb abb" 0 4 4 7
abc abc 0 3
abc " abc abcabc " 1 4 5 8 8 11
\n\n " \n\n\n \n \n\n\n\n " 1 3 18 20 20 22
$ " \n\n \n\n\n" 3 3 4 4 7 7 8 8 9 9 10 10
\b " abb a abbb " 2 2 5 5 6 6 7 7 8 8 12 12
- match_default normal REG_EXTENDED REG_STARTEND REG_GREP REG_ICASE
A " a a a aa" 1 2 3 4 5 6 7 8 8 9
A+B+ "aabaabbb ab" 0 3 3 8 9 11
A(B*|c|e)D adabbdacd 0 2 2 6 6 9
A "\na\na\na\naa" 1 2 3 4 5 6 7 8 8 9
^aB "Ab \nab Ab\n" 0 2 5 7
\<abc "Abcabc aBc\n\nabc" 0 3 7 10 12 15
ABC abc 0 3
abc " ABC ABCABC " 1 4 5 8 8 11
;
; now test merge,
;
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_no_copy
; start by testing subs:
a+ "...aaa,,," $` "..."
a+ "...aaa,,," $' ",,,"
a+ "...aaa,,," $& "aaa"
a+ "...aaa,,," $0 aaa
a+ "...aaa,,," $1 ""
a+ "...aaa,,," $15 ""
(a+)b+ "...aaabbb,,," $1 aaa
[[:digit:]]* 123ab <$0> <123><><><>
[[:digit:]]* 123ab1 <$0> <123><><><1>
; and now escapes:
a+ "...aaa,,," $x "$x"
a+ "...aaa,,," \a "\a"
a+ "...aaa,,," \f "\f"
a+ "...aaa,,," \n "\n"
a+ "...aaa,,," \r "\r"
a+ "...aaa,,," \t "\t"
a+ "...aaa,,," \v "\v"
a+ "...aaa,,," \x21 "!"
a+ "...aaa,,," \x{21} "!"
a+ "...aaa,,," \c@ \0
a+ "...aaa,,," \e \27
a+ "...aaa,,," \0101 A
a+ "...aaa,,," (\0101) A
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_sed format_no_copy
(a+)(b+) ...aabb,, \0 aabb
(a+)(b+) ...aabb,, \1 aa
(a+)(b+) ...aabb,, \2 bb
(a+)(b+) ...aabb,, & aabb
(a+)(b+) ...aabb,, $ $
(a+)(b+) ...aabb,, $1 $1
(a+)(b+) ...aabb,, ()?: ()?:
(a+)(b+) ...aabb,, \\ \\
(a+)(b+) ...aabb,, \& &
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_perl format_no_copy
(a+)(b+) ...aabb,, $0 aabb
(a+)(b+) ...aabb,, $1 aa
(a+)(b+) ...aabb,, $2 bb
(a+)(b+) ...aabb,, $& aabb
(a+)(b+) ...aabb,, & &
(a+)(b+) ...aabb,, \0 \0
(a+)(b+) ...aabb,, ()?: ()?:
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE
; move to copying unmatched data:
a+ "...aaa,,," bbb "...bbb,,,"
a+(b+) "...aaabb,,," $1 "...bb,,,"
a+(b+) "...aaabb,,,ab*abbb?" $1 "...bb,,,b*bbb?"
(a+)|(b+) "...aaabb,,,ab*abbb?" (?1A)(?2B) "...AB,,,AB*AB?"
(a+)|(b+) "...aaabb,,,ab*abbb?" ?1A:B "...AB,,,AB*AB?"
(a+)|(b+) "...aaabb,,,ab*abbb?" (?1A:B)C "...ACBC,,,ACBC*ACBC?"
(a+)|(b+) "...aaabb,,,ab*abbb?" ?1:B "...B,,,B*B?"
- match_default normal REG_EXTENDED REG_STARTEND REG_MERGE format_first_only
; move to copying unmatched data, but replace first occurance only:
a+ "...aaa,,," bbb "...bbb,,,"
a+(b+) "...aaabb,,," $1 "...bb,,,"
a+(b+) "...aaabb,,,ab*abbb?" $1 "...bb,,,ab*abbb?"
(a+)|(b+) "...aaabb,,,ab*abbb?" (?1A)(?2B) "...Abb,,,ab*abbb?"
;
; changes to newline handling with 2.11:
;
- match_default normal REG_EXTENDED REG_STARTEND REG_GREP
^. " \n \r\n " 0 1 3 4 7 8
.$ " \n \r\n " 1 2 4 5 8 9
- match_default normal REG_EXTENDED REG_STARTEND REG_GREP REG_UNICODE_ONLY
^. " \8232 \8233 " 0 1 3 4 5 6
.$ " \8232 \8233 " 1 2 3 4 6 7
;
; non-greedy repeats added 21/04/00
- match_default normal REG_EXTENDED
a** !
a*? aa 0 0
a?? aa 0 0
a++ !
a+? aa 0 1
a{1,3}{1} !
a{1,3}? aaa 0 1
\w+?w ...ccccccwcccccw 3 10
\W+\w+?w ...ccccccwcccccw 0 10
abc|\w+? abd 0 1
abc|\w+? abcd 0 3
<\s*tag[^>]*>(.*?)<\s*/tag\s*> " <tag>here is some text</tag> <tag></tag>" 1 29 6 23
<\s*tag[^>]*>(.*?)<\s*/tag\s*> " < tag attr=\"something\">here is some text< /tag > <tag></tag>" 1 49 24 41
;
; non-marking parenthesis added 25/04/00
- match_default normal REG_EXTENDED
(?:abc)+ xxabcabcxx 2 8
(?:a+)(b+) xaaabbbx 1 7 4 7
(a+)(?:b+) xaaabbba 1 7 1 4
(?:(a+)b+) xaaabbba 1 7 1 4
(?:a+(b+)) xaaabbba 1 7 4 7
a+(?#b+)b+ xaaabbba 1 7
(a)(?:b|$) ab 0 2 0 1
(a)(?:b|$) a 0 1 0 1
;
; try some partial matches:
- match_partial match_default normal REG_EXTENDED REG_NO_POSIX_TEST
(xyz)(.*)abc xyzaaab -1 -1 0 3 3 7
(xyz)(.*)abc xyz -1 -1 0 3 3 3
(xyz)(.*)abc xy -1 -1 -1 -1 -1 -1
;
; forward lookahead asserts added 21/01/02
- match_default normal REG_EXTENDED REG_NO_POSIX_TEST
((?:(?!a|b)\w)+)(\w+) " xxxabaxxx " 2 11 2 5 5 11
/\*(?:(?!\*/).)*\*/ " /**/ " 2 6
/\*(?:(?!\*/).)*\*/ " /***/ " 2 7
/\*(?:(?!\*/).)*\*/ " /********/ " 2 12
/\*(?:(?!\*/).)*\*/ " /* comment */ " 2 15
<\s*a[^>]*>((?:(?!<\s*/\s*a\s*>).)*)<\s*/\s*a\s*> " <a href=\"here\">here</a> " 1 24 16 20
<\s*a[^>]*>((?:(?!<\s*/\s*a\s*>).)*)<\s*/\s*a\s*> " <a href=\"here\">here< / a > " 1 28 16 20
<\s*a[^>]*>((?:(?!<\s*/\s*a\s*>).)*)(?=<\s*/\s*a\s*>) " <a href=\"here\">here</a> " 1 20 16 20
<\s*a[^>]*>((?:(?!<\s*/\s*a\s*>).)*)(?=<\s*/\s*a\s*>) " <a href=\"here\">here< / a > " 1 20 16 20
; filename matching:
^(?!^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(?:\..+)?$)[^\x00-\x1f\\?*:\"|/]+$ command.com 0 11
^(?!^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(?:\..+)?$)[^\x00-\x1f\\?*:\"|/]+$ PRN -1 -1
^(?!^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(?:\..+)?$)[^\x00-\x1f\\?*:\"|/]+$ COM2 -1 -1
; password checking:
^(?=.*\d).{4,8}$ abc3 0 4
^(?=.*\d).{4,8}$ abc3def4 0 8
^(?=.*\d).{4,8}$ ab2 -1 -1
^(?=.*\d).{4,8}$ abcdefg -1 -1
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ abc3 -1 -1
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ abC3 0 4
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ ABCD3 -1 -1