#Copyright (C) 2010 Dr. Alistair Ward # #This program is free software: you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation, either version 3 of the License, or #(at your option) any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program. If not, see . #AUTHOR: Dr. Alistair Ward #DESCRIPTION: Designed to be read by the module "FunctionAlley.RegExChar.Assert.RegExOptsChar". #CAVEAT: Regrettably, "Text.Regex.Posix" actually dies when presented with some of these, so they've been commented-out. ("^$", [("", [(0,0)])]) ("^a.[cd][^ef]$", [("abcg", [(0,4)]),("aBdE", [(0,4)])]) ("^a*.*[cd]*[^ef]*$", [("", [(0,0)]),("a", [(0,1)]),("ab", [(0,2)]),("aBc", [(0,3)]),("ac", [(0,2)]),("acd", [(0,3)]),("abcdgh", [(0,6)])]) ("^a*?.*?[cd]*?[^e]*?$", [("", [(0,0)]),("a", [(0,1)]),("ab", [(0,2)]),("aBc", [(0,3)]),("ac", [(0,2)]),("acd", [(0,3)]),("abcdf", [(0,5)])]) ("^a+.+[cd]+[^ef]+$", [("abcg", [(0,4)]),("aaBcG", [(0,5)]),("aBBcg", [(0,5)]),("abBcdG", [(0,6)])]) ("^a+?.+?[cd]+?[^e]+?$", [("abcf", [(0,4)]),("aaBcF", [(0,5)]),("aBBcE", [(0,5)]),("abBcdg", [(0,6)])]) ("^a?.?[cd]?[^ef]?$", [("", [(0,0)]),("a", [(0,1)]),("ab", [(0,2)]),("aBc", [(0,3)]),("ac", [(0,2)]),("acd", [(0,3)]),("abcg", [(0,4)])]) ("^a??.??[cd]??[^ef]??$", [("", [(0,0)]),("a", [(0,1)]),("ab", [(0,2)]),("aBc", [(0,3)]),("ac", [(0,2)]),("acd", [(0,3)]),("abcE", [(0,4)])]) ("^a{2}.{1,2}[cd]{1,}[^ef]{2,3}$", [("aabcEF", [(0,6)]),("aaBbcdEFE", [(0,9)])]) ("^.{1,2}?[cd]{1,}?[^ef]{2,3}?$", [("bcEF", [(0,4)]),("BbcdEFE", [(0,7)])]) #("^[^][a][bb]?$", [("xa", [(0,2)]),("xab", [(0,3)])]) #Is this legal ? #("^[]*$", [("", [(0,0)])]) #Is this legal ? #Escape-sequences. ("^\\[]$", [("[]", [(0,2)])]) ("^\\\\+$", [("\\", [(0,1)]),("\\\\", [(0,2)]),("\\\\\\", [(0,3)])]) ("^[\\\\]+$", [("\\", [(0,1)]),("\\\\", [(0,2)]),("\\\\\\", [(0,3)])]) ("\\^\\$", [("^$", [(0,2)])]) #Non-greedy. ("^aa?a*a+$", [("aa", [(0,2)]),("aaa", [(0,3)]),("aaaa", [(0,4)])]) ("^a+?[^a]+?a+[^a]+$", [("abab", [(0,4)]),("aabbaabb", [(0,8)]),("aaabbbaaabbb", [(0,12)])]) ("^a.*?$", [("a", [(0,1)]),("ab", [(0,2)]),("abc", [(0,3)])]) ("^.*?a$", [("a", [(0,1)]),("ba", [(0,2)]),("cba", [(0,3)])]) ("^.*?a.*?$", [("a", [(0,1)]),("ab", [(0,2)]),("ba", [(0,2)]),("bab", [(0,3)])]) #Shortcuts. ("^\\S\\s+\\S$", [("a \t\r\n b", [(0,7)])]) ("^\\d\\D+\\d$", [("0aA_!@#$%^&*()-=+;:',<.>/?9", [(0,27)])]) #"Text.Regex.Posix" doesn't understand these Perl-shortcuts. ("^\\w+$", [("aA_09", [(0,5)])]) ("^\\W+$", [("!@#$%^&*()-=+;:',<.>/?", [(0,22)])]) ("^[\\d]*[\\D]*$", [("", [(0,0)]),("0123456809", [(0,10)]),("abc", [(0,3)]),("012abc", [(0,6)])]) #"Text.Regex.Posix" doesn't understand these Perl-shortcuts. ("^\\S[\\sx\\d]\\D$", [("_ _", [(0,3)]),("01a", [(0,3)]),("a\t ", [(0,3)]),("_x_", [(0,3)])]) #"Text.Regex.Posix" doesn't understand '\\d' or '\\D'. ("^[^\\d]*$", [("abc", [(0,3)]),("_ \t", [(0,3)])]) #Posix Character-classes. ("^[[:xdigit:]]*$", [("", [(0,0)]),("0123456789abcdefABCDEF", [(0,22)])]) #user error (Text.Regex.Posix.String died: (ReturnCode 4,"Invalid character class name")) #("^[[:^xdigit:]]*$", [("", [(0,0)]),("ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ", [(0,40)])]) #("^[^[:^xdigit:]]*$", [("", [(0,0)]),("0123456789abcdefABCDEF", [(0,22)])]) #("^[a[:digit:]z]*$", [("", [(0,0)]),("012", [(0,3)]),("z210a", [(0,5)])]) #("^[^a[:digit:]z]*$", [("", [(0,0)]),("_bc", [(0,3)])]) #("^[^0[:^digit:]1]*$", [("", [(0,0)]),("23456789", [(0,8)])]) #Bracket-expressions. ("^[a-z0-9]$", [("b", [(0,1)]),("y", [(0,1)]),("1", [(0,1)]),("8", [(0,1)])]) #("^[-b-b-a-]$", [("-", [(0,1)]),("b", [(0,1)]),("a", [(0,1)])]) #user error (Text.Regex.Posix.String died: (ReturnCode 11,"Invalid range end")) #Sub-expressions. ("^a+(b?)*c{2,3}$", [("acc", [(0,3),(-1, 0)]),("aabccc", [(0,6),(2,1)]),("abbbcc", [(0,6),(3,1)])]) #For 1st data-set, "Text.Regex.Posix" returns [(0,3),(1,0)]. ("^a+(b?|c+?[de]{1,2})*f$", [("af", [(0,2),(1,0)]),("aabf", [(0,4),(2,1)]),("aaacdf", [(0,6),(3,2)]),("abccdef", [(0,7),(2,4)])]) ("^a+(b?(c|de)+?f)+g$", [("abcfg", [(0,5),(1,3),(2,1)]),("aadecfbcfg", [(0,10),(6,3),(7,1)])]) #Alternatives. ("^(a|.|[cd]|[^ef])$", [("a", [(0,1),(0,1)]),("b", [(0,1),(0,1)]),("c", [(0,1),(0,1)]),("E", [(0,1),(0,1)])]) ("^(a*|.*?|[cd]*|[^ef]*?)$", [("", [(0,0),(0,0)]),("aa", [(0,2),(0,2)]),("bb", [(0,2),(0,2)]),("dc", [(0,2),(0,2)]),("EF", [(0,2),(0,2)])]) ("^(a+|.+?|[cd]+|[^ef]+?)$", [("aa", [(0,2),(0,2)]),("bb", [(0,2),(0,2)]),("dc", [(0,2),(0,2)]),("FE", [(0,2),(0,2)])]) ("^(a?|.??|[cd]?|[^ef]??)$", [("", [(0,0),(0,0)]),("a", [(0,1),(0,1)]),("b", [(0,1),(0,1)]),("c", [(0,1),(0,1)]),("E", [(0,1),(0,1)])]) ("^(a{2}|.{1,2}?|[cd]{1,}|[^ef]{2,3}?)$", [("aa", [(0,2),(0,2)]),("b", [(0,1),(0,1)]),("cddc", [(0,4),(0,4)]),("EF", [(0,2),(0,2)])]) ("^(.*){2}.$", [("a", [(0,1),(0,0)])]) ("^(a|[^a])*$", [("", [(0,0),(-1,0)]),("a", [(0,1),(0,1)]),("b", [(0,1),(0,1)]),("aa", [(0,2),(1,1)]),("ab", [(0,2),(1,1)]),("bb", [(0,2),(1,1)]),("ba", [(0,2),(1,1)])]) #"Text.Regex.Posix" returns [(0,0),(-1,0)] for the 1st data-set, which looks correct. ("^(a|b*)*$", [("", [(0,0),(-1,0)]),("a", [(0,1),(0,1)]),("b", [(0,1),(0,1)]),("aa", [(0,2),(1,1)]),("ab", [(0,2),(1,1)]),("bb", [(0,2),(0,2)]),("ba", [(0,2),(1,1)])]) ("^(a*)+b$", [("b", [(0,1),(0,0)]),("ab", [(0,2),(0,1)])]) ("^(a|bc|def)+$", [("abcdef", [(0,6),(3,3)]),("defbca", [(0,6),(5,1)])]) ("^a(b(c|de|fgh){1,3}i|j(k|lm|nop)+q)*r$", [("abcdefghijklmnopqr", [(0,18),(9,8),(13,3)]),("ar", [(0,2),(-1, 0)]),("abfghdecijnoplmkqr", [(0,18),(9,8),(15,1)]),("ajnoplmkqbfghdecir", [(0,18),(9,8),(15,1)]),("abcijklmnopklmnopqbdeijklmnopklmnopqr", [(0,37),(22,14),(32,3)])]) #"Text.Regex.Posix" returns; [[(0,18),(9,8),(5,3),(13,3)], [(0,2),(-1,0),(-1,0),(-1,0)], [(0,18),(9,8),(7,1),(15,1)], [(0,37),(22,14),(19,2),(32,3)]]. ("^(((a*?)*?)*?|a*b)$", [("b", [(0,1),(0,1)]),("ab", [(0,2),(0,2)]),("aab", [(0,3),(0,3)]),("aaab", [(0,4),(0,4)])]) #"Text.Regex.Posix" returns [(0,1),(-1,0),(-1,0)], ... #Internal anchors. ("a*(^b+)*c*", [("abbc", [(0,1),(-1,0)]), ("abb", [(0,1),(-1,0)]), ("bbc", [(0,3),(0,2)]), ("ac", [(0,2),(-1,0)]), ("a", [(0,1),(-1,0)]), ("bb", [(0,2),(0,2)]), ("c", [(0,1),(-1,0)])]) ("a*(b+$)*c*", [("abbc", [(0,1),(-1,0)]), ("abb", [(0,3),(1,2)]), ("bbc", [(2,1),(-1,0)]), ("ac", [(0,2),(-1,0)]), ("a", [(0,1),(-1,0)]), ("bb", [(0,2),(0,2)]), ("c", [(0,1),(-1,0)])]) #3rd fails. ("a*(^b+$)*c*", [("abbc", [(0,1),(-1,0)]), ("abb", [(0,1),(-1,0)]), ("bbc", [(2,1),(-1,0)]), ("ac", [(0,2),(-1,0)]), ("a", [(0,1),(-1,0)]), ("bb", [(0,2),(0,2)]), ("c", [(0,1),(-1,0)])]) #3rd fails. ("a*(^b?|^b+)*c*", [("abbc", [(0,1),(-1,0)]), ("abb", [(0,1),(-1,0)]), ("bbc", [(0,3),(0,2)]), ("ac", [(0,2),(-1,0)]), ("a", [(0,1),(-1,0)]), ("bb", [(0,2),(0,2)]), ("c", [(0,1),(0,0)])]) ("(^a*|b+|c*$)*", [("abbc", [(0,4),(3,1)]), ("abb", [(0,3),(1,2)]), ("bbc", [(0,3),(2,1)]), ("ac", [(0,2),(1,1)]), ("a", [(0,1),(0,1)]), ("bb", [(0,2),(0,2)]), ("c", [(0,1),(0,1)])]) #"Text.Regex.Posix" doesn't return from either 3rd or 6th.