description = '''
anchor, word boundary, character class, quantifier, alternation, and real-world tests.
matches = [[start, end]] in utf8 bytes (half-open intervals).
'''
[[test]]
name = "exact_string"
pattern = '^\A([^\: \t]+):\s*(.+)\z'
input = "\n:!"
matches = [[0, 3]]
[[test]]
name = "anchor_digit_exact"
pattern = '^\d$'
input = "1"
matches = [[0, 1]]
[[test]]
name = "anchor_z_bare"
pattern = '\z'
input = "abc"
matches = [[3, 3]]
[[test]]
name = "anchor_A_bare"
pattern = '\A'
input = "abc"
matches = [[0, 0]]
[[test]]
name = "string_anchor_A_z_star_no_match"
pattern = '\A[a-zA-Z]*\z'
input = "(asdf)asdf"
matches = []
[[test]]
name = "string_anchor_A_z_plus_no_match"
pattern = '\A[a-zA-Z]+\z'
input = "(asdf)asdf"
matches = []
[[test]]
name = "string_anchor_A_z_plus_match"
pattern = '\A[a-zA-Z]+\z'
input = "asdfasdf"
matches = [[0, 8]]
[[test]]
name = "string_anchor_A_z_star_match"
pattern = '\A[a-zA-Z]*\z'
input = "asdfasdf"
matches = [[0, 8]]
[[test]]
name = "anchor_digit_exact_no_match_multidigit"
pattern = '^\d$'
input = "324"
matches = []
[[test]]
name = "anchor_digit_exact_no_match_alpha"
pattern = '^\d$'
input = "a"
matches = []
[[test]]
name = "anchor_digits_star"
pattern = '^\d*$'
input = "123"
matches = [[0, 3]]
[[test]]
name = "anchor_length_range_too_short"
pattern = '^.{4,8}$'
input = "asd"
matches = []
[[test]]
name = "anchor_length_range_min"
pattern = '^.{4,8}$'
input = "asdf"
matches = [[0, 4]]
[[test]]
name = "anchor_length_range_max"
pattern = '^.{4,8}$'
input = "asdfghjk"
matches = [[0, 8]]
[[test]]
name = "anchor_length_range_too_long"
pattern = '^.{4,8}$'
input = "asdfghjkl"
matches = []
[[test]]
name = "anchor_version_string_2_0"
pattern = '\A[0-2](\.[0-9]+)+\z'
input = "2.0"
matches = [[0, 3]]
[[test]]
name = "anchor_version_string_1_2_3"
pattern = '\A[0-2](\.[0-9]+)+\z'
input = "1.2.3"
matches = [[0, 5]]
[[test]]
name = "anchor_version_string_3_0"
pattern = '\A[0-2](\.[0-9]+)+\z'
input = "3.0"
matches = []
[[test]]
name = "anchor_empty_no_match"
pattern = "^Purchase receipt$"
input = ""
matches = []
[[test]]
name = "anchor_decimal"
pattern = '^\d*\.?\d*$'
input = "3.14159"
matches = [[0, 7]]
[[test]]
name = "word_boundary_11_bare"
pattern = '\b11\b'
input = "11"
matches = [[0, 2]]
[[test]]
name = "word_boundary_11_leading_space"
pattern = '\b11\b'
input = " 11"
matches = [[1, 3]]
[[test]]
name = "word_boundary_11_trailing_space"
pattern = '\b11\b'
input = "11 "
matches = [[0, 2]]
[[test]]
name = "word_boundary_11_both_spaces"
pattern = '\b11\b'
input = " 11 "
matches = [[1, 3]]
[[test]]
name = "word_boundary_partial_leading"
pattern = '\b11'
input = " 11"
matches = [[1, 3]]
[[test]]
name = "word_boundary_partial_trailing_bare"
pattern = '11\b'
input = "11"
matches = [[0, 2]]
[[test]]
name = "word_boundary_partial_trailing_space"
pattern = '11\b'
input = "11 "
matches = [[0, 2]]
[[test]]
name = "word_boundary_contains_a"
pattern = '\b\w*a\w*\b'
input = "ffaff"
matches = [[0, 5]]
[[test]]
name = "word_boundary_then_any"
pattern = 'a\b.*'
input = "a-ffff"
matches = [[0, 6]]
[[test]]
name = "word_boundary_trailing"
pattern = 'a\b'
input = "a "
matches = [[0, 1]]
[[test]]
name = "word_boundary_dash_1"
pattern = '\b-'
input = "1-2"
matches = [[1, 2]]
[[test]]
name = "word_boundary_dash_2"
pattern = '1\b-'
input = "1-2"
matches = [[0, 2]]
[[test]]
name = "word_boundary_dash_3"
pattern = '1\b-2'
input = "1-2"
matches = [[0, 3]]
[[test]]
name = "charclass_negated_bounded_4"
pattern = 'a[^a]{0,4}a'
input = " a____a "
matches = [[1, 7]]
[[test]]
name = "charclass_negated_bounded_5"
pattern = 'a[^a]{0,5}a'
input = " a____a "
matches = [[1, 7]]
[[test]]
name = "charclass_slash_dot"
pattern = "[a-z0-9.-]{1,}/[a-z0-9.-_]{1,}"
input = "a/."
matches = [[0, 3]]
[[test]]
name = "charclass_quoted_punct_match"
pattern = '''["'][^"']{0,30}[?!\.]["']'''
input = ' "hello!" '
matches = [[1, 9]]
[[test]]
name = "charclass_quoted_punct_no_match"
pattern = '''["'][^"']{0,30}[?!\.]["']'''
input = ' hello!" '
matches = []
[[test]]
name = "quantifier_bounded_repeat_1"
pattern = "ab{0,5}c"
input = "bbabbbbbc"
matches = [[2, 9]]
[[test]]
name = "quantifier_bounded_repeat_2"
pattern = "ab{0,5}c"
input = "bbbabbbbc"
matches = [[3, 9]]
[[test]]
name = "quantifier_bounded_repeat_3"
pattern = "ab{0,5}c"
input = "bbbbabbbc"
matches = [[4, 9]]
[[test]]
name = "quantifier_bounded_repeat_4"
pattern = "ab{0,5}c"
input = "bbbbbbbac"
matches = [[7, 9]]
[[test]]
name = "quantifier_bounded_repeat_5"
pattern = "ab{0,5}c"
input = "bbabbbcbbac"
matches = [[2, 7], [9, 11]]
[[test]]
name = "quantifier_group_plus"
pattern = "(ab)+"
input = "__abab__ab__"
matches = [[2, 6], [8, 10]]
[[test]]
name = "quantifier_a_plus"
pattern = "a+"
input = " aaa "
matches = [[1, 4]]
[[test]]
name = "quantifier_a_star_1"
pattern = "a*"
input = "bbbbaaabbbbb"
matches = [[0,0],[1,1],[2,2],[3,3],[4,7],[7,7],[8,8],[9,9],[10,10],[11,11],[12,12]]
[[test]]
name = "quantifier_a_star_2"
pattern = "a*"
input = "bbbb"
matches = [[0,0],[1,1],[2,2],[3,3],[4,4]]
[[test]]
name = "quantifier_wildcard_star"
pattern = "_*"
input = ""
matches = [[0, 0]]
[[test]]
name = "quantifier_greedy_a3"
pattern = ".*a{3}"
input = "aa aaa"
matches = [[0, 6]]
[[test]]
name = "alt_or_any"
pattern = ".*b|a"
input = " aaab "
matches = [[0, 5]]
[[test]]
name = "dot_dot_g"
pattern = "..g"
input = "dfdff dfggg gfgdfg gddfdf"
matches = [[6, 9], [10, 13], [15, 18]]
[[test]]
name = "real_ip_address"
pattern = '^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$'
input = "0.0.0.0"
matches = [[0, 7]]
[[test]]
name = "real_phone_intl"
pattern = '^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$'
input = "(+44)(0)20-12341234"
matches = [[0, 19]]
[[test]]
name = "real_phone_us"
pattern = '^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$'
input = "1-(123)-123-1234"
matches = [[0, 16]]
[[test]]
name = "real_address_no_match"
pattern = '\d{1,3}.?\d{0,3}\s[a-zA-Z]{2,30}\s[a-zA-Z]{2,15}'
input = "65 Beechworth/ Rd"
matches = []
[[test]]
name = "real_date"
pattern = '((\d{2})|(\d))\/((\d{2})|(\d))\/((\d{4})|(\d{2}))'
input = "4/05/89"
matches = [[0, 7]]
[[test]]
name = "real_port_range"
pattern = '^(6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])$'
input = "65535"
matches = [[0, 5]]
[[test]]
name = "real_currency_no_match"
pattern = '(^\d{3,5}\,\d{2}$)|(^\d{3,5}$)'
input = "1300333444"
matches = []
[[test]]
name = "real_large_alternation"
pattern = "[du]{2}|[gu]{2}|[tu]{2}|[ds]{2}|[gs]{2}|[da]{2}|[ga]{2}|[ta]{2}|[dq]{2}|[gq]{2}|[tq]{2}|[DU]{2}|[GU]{2}|[TU]{2}|[DS]{2}|[GS]{2}|[DA]{2}|[GA]{2}|[TA]{2}|[DQ]{2}|[GQ]{2}|[TQ]{2}"
input = "DU"
matches = [[0, 2]]
[[test]]
name = "real_html_comment"
pattern = '<!--[\s\S]*--[ \t]*>'
input = "<!-- anything -- >"
matches = [[0, 18]]
[[test]]
name = "wildcard_contains_a"
pattern = "_*a_*"
input = "bbabb"
matches = [[0, 5]]
[[test]]
name = "wildcard_escaped_underscore"
pattern = 'a\_b*'
input = "a_b"
matches = [[0, 3]]
[[test]]
name = "wildcard_class_attr"
pattern = 'class="_*'
input = 'class="dasdasdsdasd"'
matches = [[0, 20]]
[[test]]
name = "wb_alt_begin_string_bare"
pattern = '(?<=\W|\A)11'
input = "11"
matches = [[0, 2]]
[[test]]
name = "wb_alt_begin_string_space"
pattern = '(?<=\W|\A)11'
input = " 11"
matches = [[1, 3]]
[[test]]
name = "wb_alt_end_string_bare"
pattern = '11(?=\W|\z)'
input = "11"
matches = [[0, 2]]
[[test]]
name = "wb_alt_end_string_space"
pattern = '11(?=\W|\z)'
input = "11 "
matches = [[0, 2]]
[[test]]
name = "wb_alternation_pm"
pattern = '(pm\b|p\.m\.|p\b|p m\b|p\. m\.\b|p\.m\b|p\. m\b)'
input = "p. m"
matches = [[0, 4]]
[[test]]
name = "wb_alternation_pm_simple"
pattern = '(pm\b|p\.m\.|p\b)'
input = "p. m"
matches = [[0, 1]]
[[test]]
name = "wb_alternation_pm_with_space"
pattern = '(pm\b|p\.m\.|p\b|p m\b)'
input = "p. m"
matches = [[0, 1]]
[[test]]
name = "wb_alternation_a"
pattern = '(aa|ab|a\b)'
input = "a c"
matches = [[0, 1]]
[[test]]
name = "wb_long_word_12plus"
pattern = '\b[a-z]{12,}\b'
input = "hello extraordinary world"
matches = [[6, 19]]
[[test]]
name = "wb_long_word_no_match"
pattern = '\b[a-z]{12,}\b'
input = "hello world foo"
matches = []
[[test]]
name = "wb_long_word_multiple"
pattern = '\b[a-z]{12,}\b'
input = "understanding communication"
matches = [[0, 13], [14, 27]]
[[test]]
name = "wb_long_word_mixed_case"
pattern = '\b[a-z]{12,}\b'
input = "THE understanding OF communication HERE"
matches = [[4, 17], [21, 34]]
[[test]]
name = "wb_long_word_at_start"
pattern = '\b[a-z]{12,}\b'
input = "extraordinary!"
matches = [[0, 13]]
[[test]]
name = "wb_long_word_at_end"
pattern = '\b[a-z]{12,}\b'
input = "!extraordinary"
matches = [[1, 14]]
[[test]]
name = "wb_exact_13"
pattern = '\b[a-z]{13}\b'
input = "hello world extraordinary"
matches = [[12, 25]]
[[test]]
name = "wb_exact_12_no_match"
pattern = '\b[a-z]{12}\b'
input = "hello world extraordinary"
matches = []
[[test]]
name = "wb_adjacent_words"
pattern = '\b[a-z]+\b'
input = "cat dog bird"
matches = [[0, 3], [4, 7], [8, 12]]
[[test]]
name = "wb_lowercase_words"
pattern = '\b[a-z]+\b'
input = "hello WORLD foo"
matches = [[0, 5], [12, 15]]
[[test]]
name = "wb_bounded_rep_3_5"
pattern = '\b[a-z]{3,5}\b'
input = "cat extraordinary dog bird"
matches = [[0, 3], [18, 21], [22, 26]]
[[test]]
name = "wb_no_match_embedded"
pattern = '\b11\b'
input = "a11b"
matches = []
[[test]]
name = "anchor_A_with_content"
pattern = '\Aabc'
input = "abc"
matches = [[0, 3]]
[[test]]
name = "anchor_A_no_match"
pattern = '\Aabc'
input = "xabc"
matches = []
[[test]]
name = "anchor_z_with_content"
pattern = 'abc\z'
input = "abc"
matches = [[0, 3]]
[[test]]
name = "real_date_validation"
pattern = '^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$'
input = "2004-2-29"
matches = [[0, 9]]
[[test]]
name = "caret_multiline_two_matches"
pattern = '^name'
input = "[package]\nname = \"foo\"\n[[bin]]\nname = \"bar\""
matches = [[10, 14], [31, 35]]
[[test]]
name = "caret_multiline_no_newline_consumed"
pattern = '^foo'
input = "foo\nfoo"
matches = [[0, 3], [4, 7]]
[[test]]
name = "line_anchors_counted_group"
pattern = '^[^0-9]*(?:(\d)[^0-9]*){10}$'
input = "0\n0\n0\n0\n0\n0\n0\n0\n00 0\n0\n0\n0\n0\n0\n0\n0\n00"
matches = [[2, 20]]
[[test]]
name = "anchor_union_a_z"
pattern = '(\A|(.*,))VALUE(\z|([,]?.))'
input = "VALUE"
matches = [[0, 5]]
[[test]]
name = "anchor_union_no_match"
pattern = '(\A|(.*,))VALUE(\z|([,]?.))'
input = "xxxxxVALUEyyyyy"
matches = []
[[test]]
name = "z_anchor_xs"
pattern = '\.xs\z'
input = ".xs .xs"
matches = [[4, 7]]
[[test]]
name = "a_anchor_leading_ws"
pattern = '\A(\s*)'
input = "xxxxx\tyyyyy"
matches = [[0, 0]]
[[test]]
name = "fas_begin_alt_a_plus_or_x_foo"
pattern = '(?:\Aa+|x)foo'
input = "aaaaafoo"
matches = [[0, 8]]
[[test]]
name = "fas_begin_alt_a_plus_or_x_foo_multi"
pattern = '(?:\Aa+|x)foo'
input = "aaafoo xfoo yfoo"
matches = [[0, 6], [7, 11]]
[[test]]
name = "fas_begin_alt_or_x_foo"
pattern = '(?:\A|x)foo'
input = "foo xfoo yfoo"
matches = [[0, 3], [4, 8]]
[[test]]
name = "fas_dotstar_foo_dollar_single"
pattern = '.*foo$'
input = "abcfoo"
matches = [[0, 6]]
[[test]]
name = "fas_dotstar_foo_dollar_long"
pattern = '.*foo$'
input = "foo bar foo"
matches = [[0, 11]]
[[test]]
name = "fas_word_boundary_foo_repeated"
pattern = '\bfoo\b'
input = "foo bar foo"
matches = [[0, 3], [8, 11]]
[[test]]
name = "fas_word_boundary_foo_middle"
pattern = '\bfoo\b'
input = "a foo b"
matches = [[2, 5]]
[[test]]
name = "fas_word_boundary_lower_words"
pattern = '\b[a-z]+\b'
input = "hello world 123 foo"
matches = [[0, 5], [6, 11], [16, 19]]
[[test]]
name = "fas_word_word_boundary"
pattern = '\w+\b'
input = "hello world foo"
matches = [[0, 5], [6, 11], [12, 15]]
[[test]]
name = "fas_lower_z_anchor"
pattern = '[a-z]+\z'
input = "abc def"
matches = [[4, 7]]
[[test]]
name = "fas_caret_lower_dollar"
pattern = '^[a-z]+$'
input = "abc"
matches = [[0, 3]]
[[test]]
name = "fas_digit_dollar"
pattern = '\d+$'
input = "abc123"
matches = [[3, 6]]
[[test]]
name = "fas_caret_dotstar_dollar"
pattern = '^.*$'
input = "abc"
matches = [[0, 3]]