|
From: creedon <icr...@us...> - 2005-08-07 23:16:34
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12884 Modified Files: expand match stressTest getPatternInfo visit replace extract comparison split grep Log Message: integrated old regex.examples table into re.testing Index: comparison =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/comparison,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** comparison 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- comparison 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.comparison ! local (s = string (regex.examples.data.bookmarks)); local { complexLinkPat = "<a[ \t\r\n]*[^>]*href[ \t\r\n]*=[ \t\r\n]*\"?([-_~%@:/\\.A-Za-z0-9]+)\"?[^>]*>([^<]*)"; theList; tt}; tt = clock.ticks(); bundle { //kernel-based theList = re.extract (re.compile (complexLinkPat), s, {1})}; Çbundle //DLL-based Çregex.extract (complexLinkPat, @s, @theList, {1}) tt = clock.ticks() - tt; dialog.notify ( tt + " ticks; " + sizeof (theList) + " elements") \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.comparison ! local (s = string (re.testing.data.bookmarks)); local { complexLinkPat = "<a[ \t\r\n]*[^>]*href[ \t\r\n]*=[ \t\r\n]*\"?([-_~%@:/\\.A-Za-z0-9]+)\"?[^>]*>([^<]*)"; theList; tt}; tt = clock.ticks(); bundle { //kernel-based theList = re.extract (re.compile (complexLinkPat), s, {1})}; tt = clock.ticks() - tt; dialog.notify (tt + " ticks; " + sizeof (theList) + " elements") \ No newline at end of file Index: getPatternInfo =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/getPatternInfo,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** getPatternInfo 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- getPatternInfo 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.getPatternInfo ! local (patternRef); patternRef = re.compile ("(?P<date>(?P<year>(\\d\\d)?\\d\\d)-(?P<month>\\d\\d)-(?P<day>\\d\\d))", flAutoCapture:false); re.getPatternInfo (patternRef, @temp.patternInfo); edit (@temp.patternInfo) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.getPatternInfo ! local (cp); cp = re.compile ("(?P<date>(?P<year>(\\d\\d)?\\d\\d)-(?P<month>\\d\\d)-(?P<day>\\d\\d))", flAutoCapture:false); re.getPatternInfo (cp, @temp.patternInfo); edit (@temp.patternInfo) \ No newline at end of file Index: grep =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/grep,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** grep 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- grep 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.grep ! local (theList = {"aa", "aab", "a", "ab", ""}); local (patternRef); patternRef = re.compile ("^aa"); dialog.notify (re.grep (patternRef, theList)); dialog.notify (re.grep (patternRef, theList, flIncludeMatches:false)); dialog.notify (re.grep (patternRef, re.join (cr, theList) + cr)); dialog.notify (re.grep (patternRef, re.join (cr, theList) + cr, flIncludeMatches:false)) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.grep ! local (theList = {"aa", "aab", "a", "ab", ""}); local (cp = re.compile ("^aa")); dialog.notify (re.grep (cp, theList)); Çdialog.notify (re.grep (re.compile (""), theList, false)) // not sure what is wrong with this, trying to get it to return all items in theList except last one; regex call was regex.grep ("", @theList, false) dialog.notify (re.grep (cp, theList, flIncludeMatches: false)); dialog.notify (re.grep (cp, re.join (cr, theList) + cr)); dialog.notify (re.grep (cp, re.join (cr, theList) + cr, flIncludeMatches: false)) \ No newline at end of file Index: split =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/split,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** split 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- split 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.split ! local (s = "<title>test</title>\r<body>\rtest body\r</body>"); local (patRef); patRef = re.compile ("<[^>]*>"); dialog.notify (re.split (patRef, s)); patRef = re.compile ("(<[^>]*>)"); dialog.notify (re.split (patRef, s, maxSplits:4)) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.split ! local (s = "<title>test</title>\r<body>\rtest body\r</body>"); dialog.notify (re.split (re.compile ("<[^>]*>"), s)); dialog.notify (re.split (re.compile ("(<[^>]*>)"), s, maxSplits: 4)) \ No newline at end of file Index: expand =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/expand,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** expand 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- expand 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.expand ! local (patternRef); patternRef = re.compile ("(?P<date>(?P<year>(\\d\\d)?\\d\\d)-(?P<month>\\d\\d)-(?P<day>\\d\\d))", flAutoCapture:false); if re.match (patternRef, "2003-05-30", adrMatchInfoTable:@temp.matchInfo, flMakeGroups:true, flMakeNamedGroups:true) { dialog.notify (re.expand ("\\g<day>.\\g<month>.\\g<year>", @temp.matchInfo)); dialog.notify (re.expand ("\\g<4>.\\g<3>.\\g<2>", @temp.matchInfo)); dialog.notify (re.expand ("\\4.\\3.\\2", @temp.matchInfo))}; edit (@temp.matchInfo) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.expand ! local (cp); cp = re.compile ("(?P<date>(?P<year>(\\d\\d)?\\d\\d)-(?P<month>\\d\\d)-(?P<day>\\d\\d))", flAutoCapture:false); if re.match (cp, "2003-05-30", adrMatchInfoTable:@temp.matchInfo, flMakeGroups:true, flMakeNamedGroups:true) { dialog.notify (re.expand ("\\g<day>.\\g<month>.\\g<year>", @temp.matchInfo)); dialog.notify (re.expand ("\\g<4>.\\g<3>.\\g<2>", @temp.matchInfo)); dialog.notify (re.expand ("\\4.\\3.\\2", @temp.matchInfo))}; edit (@temp.matchInfo) \ No newline at end of file Index: visit =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/visit,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** visit 26 Mar 2005 19:43:26 -0000 1.1.1.1 --- visit 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.visit ! local (test = " <A href ='index.html' > <A href= 'index2.html' > "); on testCallback (adrTable) { dialog.notify (string(adrTable^)); return (true)}; local (patternRef = re.compile ("<([^>]+)>")); re.visit (patternRef, test, @testCallback, flMakeGroups:true) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.visit ! local (test = " <A href ='index.html' > <A href= 'index2.html' > "); local (cp = re.compile ("<([^>]+)>")); on testCallback (adrTable) { dialog.notify (string (adrTable^)); return (true)}; re.visit (cp, test, @testCallback, flMakeGroups: true) \ No newline at end of file Index: extract =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/extract,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** extract 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- extract 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.extract ! local { complexLinkPat = "<a[ \t\r\n]*[^>]*href[ \t\r\n]*=[ \t\r\n]*\"?([-_~%@:/\\.A-Za-z0-9]+)\"?[^>]*>([^<]*)"; simpleLinkPat = "<a[ \t\r\n]+[^>]*href[ \t\r\n]*=[ \t\r\n]*\"([^\"]*)\"[^>]*>([^<]*)"; s = string (regex.examples.data.html); theList; tt; patRef}; tt = clock.ticks(); patRef = re.compile (simpleLinkPat); theList = re.extract (patRef, s, {2,1}); dialog.notify (clock.ticks () - tt + " ticks; " + string (theList)) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.extract ! local { complexLinkPat = "<a[ \t\r\n]*[^>]*href[ \t\r\n]*=[ \t\r\n]*\"?([-_~%@:/\\.A-Za-z0-9]+)\"?[^>]*>([^<]*)"; simpleLinkPat = "<a[ \t\r\n]+[^>]*href[ \t\r\n]*=[ \t\r\n]*\"([^\"]*)\"[^>]*>([^<]*)"; cp = re.compile (simpleLinkPat); s = string (re.testing.data.html); theList; tt = clock.ticks ()}; theList = re.extract (cp, s, {2,1}); dialog.notify (clock.ticks () - tt + " ticks; " + string (theList)) \ No newline at end of file Index: stressTest =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/stressTest,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** stressTest 26 Mar 2005 19:43:26 -0000 1.1.1.1 --- stressTest 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.stressTest ! if defined (system.compiler.["kernel"].re) { bundle { //re.match local (patternRef, matchInfo, s1 = "a123four", s2 = "bop bebe bop"); patternRef = re.compile ("[a-zA-Z]+[0-9]+"); if not re.match (patternRef, s1, adrMatchInfoTable:@matchInfo) { scripterror ("re.match is broken.")}; if matchInfo.matchString != "a123" { scripterror ("re.match is broken.")}; patternRef = re.compile ("(be){1,2}"); if not re.match (patternRef, s2, adrMatchInfoTable:@matchInfo) { scripterror ("re.search is broken.")}; if matchInfo.matchString != "bebe" { scripterror ("re.search is broken.")}}; bundle { //re.extract local { patternRef; complexLinkPat = "<a[ \t\r\n]*[^>]*href[ \t\r\n]*=[ \t\r\n]*\"?([-_~%@:/\\.A-Za-z0-9]+)\"?[^>]*>([^<]*)"; simpleLinkPat = "<a[ \t\r\n]+[^>]*href[ \t\r\n]*=[ \t\r\n]*\"([^\"]*)\"[^>]*>([^<]*)"; s = string (regex.examples.data.html); theList}; patternRef = re.compile (simpleLinkPat); theList = re.extract (patternRef, s, {2,1}); if sizeOf (theList) != 59 { scripterror ("re.extract is broken.")}; if theList[57][1] != "Roget's Thesaurus:" { scripterror ("re.extract is broken.")}; if theList[57][2] != "http://www2.thesaurus.com/thesaurus/" { scripterror ("re.extract is broken.")}; patternRef = re.compile (simpleLinkPat); theList = re.extract (patternRef, s, {2,1}); if sizeOf (theList) != 59 { scripterror ("re.extract is broken.")}; if theList[25][1] != "FileMaker" { scripterror ("re.extract is broken.")}; if theList[25][2] != "http://www.scripting.com/apps/filemaker.html" { scripterror ("re.extract is broken.")}}; bundle { //re.grep local (patternRef); local (theList = {"aa", "aab", "a", "ab", ""}); local (s = "aa\raab\ra\rab\r\r"); patternRef = re.compile ("^aa"); if re.grep (patternRef, theList) != {"aa", "aab"} { scripterror ("re.grep is broken.")}; if re.grep (patternRef, s) != {"aa", "aab"} { scripterror ("re.grep is broken.")}; if re.grep (patternRef, theList, flIncludeMatches:false) != {"a", "ab", ""} { scripterror ("re.grep is broken.")}; if re.grep (patternRef, s, flIncludeMatches:false) != {"a", "ab", ""} { scripterror ("re.grep is broken.")}}; bundle { //re.join local (listA = {"a", "b", "c"}, listB = {"abcd", "", "efgh", ""}); if re.join ("|", listA) != "a|b|c" { scripterror ("re.join is broken.")}; if re.join ("", listA) != "abc" { scripterror ("re.join is broken.")}; if re.join ("+/+", listB) != "abcd+/++/+efgh+/+" { scripterror ("re.join is broken.")}}; bundle { //re.split local (patternRef); local (s = "<title>test</title>\r<body>\rtest body\r</body>"); patternRef = re.compile ("<[^>]*>"); if re.split (patternRef, s) != {"", "test", "\r", "\rtest body\r", ""} { scripterror ("re.split is broken.")}; if re.split (patternRef, s, maxSplits:4) != {"", "test", "\r", "\rtest body\r</body>"} { scripterror ("re.split is broken.")}; patternRef = re.compile ("(<[^>]*>)"); if re.split (patternRef, s) != {"", "<title>", "test", "</title>", "\r", "<body>", "\rtest body\r", "</body>", ""} { scripterror ("re.split is broken.")}; if re.split (patternRef, s, maxSplits:3) != {"", "<title>", "test", "</title>", "\r<body>\rtest body\r</body>"} { scripterror ("re.split is broken.")}; local (s2 = "aBcDeFg"); patternRef = re.compile ("[a-z]+", flCaseSensitive:true); if re.split (patternRef, s2) != {"", "B", "D", "F", ""} { scripterror ("re.split is broken.")}; patternRef = re.compile ("[^a-z]+", flCaseSensitive:true); if re.split (patternRef, s2) != {"a", "c", "e", "g"} { scripterror ("re.split is broken.")}; patternRef = re.compile ("[A-Z]+", flCaseSensitive:true); if re.split (patternRef, s2) != {"a", "c", "e", "g"} { scripterror ("re.split is broken.")}; patternRef = re.compile ("[^A-Z]+", flCaseSensitive:true); if re.split (patternRef, s2) != {"", "B", "D", "F", ""} { scripterror ("re.split is broken.")}}; bundle { //re.replace local (patternRef, ct); local (s = "To be or not to be", s2); patternRef = re.compile ("(be)"); s = re.replace (patternRef, "\\1BOP", s); if s != "To beBOP or not to beBOP" { scripterror ("re.replace is broken")}; patternRef = re.compile ("(be)(bop)", flCaseSensitive:false); s = re.replace (patternRef, "\\2\\1", s); if s != "To BOPbe or not to BOPbe" { scripterror ("re.replace is broken")}; patternRef = re.compile ("(BOP)(be)"); s = re.replace (patternRef, "\\2\\1", s, maxReplacements:1); if s != "To beBOP or not to BOPbe" { scripterror ("re.replace is broken")}; patternRef = re.compile ("(BOP)(be)"); s = re.replace (patternRef, "\\2\\1", s, adrReplacementCount:@ct); if s != "To beBOP or not to beBOP" { scripterror ("re.replace is broken")}; if ct != 1 { scripterror ("re.replace is broken")}; local (test = "Check http://www.muppets.com/~gonzo/ for more info, send your q's to mailto:go...@mu...."); local (result = "Check <A HREF=\"http://www.muppets.com/~gonzo/\">http://www.muppets.com/~gonzo/</A> for more info, send your q's to <A HREF=\"mailto:go...@mu...\">mailto:go...@mu...</A>."); patternRef = re.compile ("(http|mailto)(:[/]*[A-Za-z0-9]+[-_~%@:/\\.A-Za-z0-9]+[A-Za-z/0-9])"); test = re.replace (patternRef, "<A HREF=\"\\1\\2\">\\0</A>", test); if test != result { scripterror ("re.replace is broken.")}}; bundle { //re.visit local (hits = 0); local (test = " <A href ='index.html' > <A href= 'index2.html' > "); on testCallback (adrTable) { case ++hits { 1 { if adrTable^.matchOffset != 2 { scripterror ("re.visit is broken.")}; if adrTable^.matchLength != 25 { scripterror ("re.visit is broken.")}; if adrTable^.matchString != "<A href ='index.html' >" { scripterror ("re.visit is broken.")}}; 2 { if adrTable^.matchOffset != 28 { scripterror ("re.visit is broken.")}; if adrTable^.matchLength != 33 { scripterror ("re.visit is broken.")}; if adrTable^.matchString != "<A href= 'index2.html' >" { scripterror ("re.visit is broken.")}}} else { scripterror ("re.visit is broken.")}; return (true)}; local (patternRef = re.compile ("<([^>]+)>")); re.visit (patternRef, test, @testCallback); if hits != 2 { scripterror ("re.visit is broken.")}}; bundle { //re.expand local (pat, mi); pat = re.compile ("(?P<date>(?P<year>(\\d\\d)?\\d\\d)-(?P<month>\\d\\d)-(?P<day>\\d\\d))", flAutoCapture:false); if re.match (pat, "2003-05-30", adrMatchInfoTable:@mi, flMakeGroups:true, flMakeNamedGroups:true) { if re.expand ("\\g<day>.\\g<month>.\\g<year>", @mi) != "30.05.2003" { scripterror ("re.expand is broken")}; if re.expand ("\\g<4>.\\g<3>.\\g<2>", @mi) != "30.05.2003" { scripterror ("re.expand is broken")}; if re.expand ("\\4.\\3.\\2", @mi) != "30.05.2003" { scripterror ("re.expand is broken")}}}}; dialog.notify ("No problems found.") \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.stressTest ! if defined (system.compiler.["kernel"].re) { bundle { //re.match local (cp, matchInfo, s1 = "a123four", s2 = "bop bebe bop"); cp = re.compile ("[a-zA-Z]+[0-9]+"); if not re.match (cp, s1, adrMatchInfoTable:@matchInfo) { scripterror ("re.match is broken.")}; if matchInfo.matchString != "a123" { scripterror ("re.match is broken.")}; cp = re.compile ("(be){1,2}"); if not re.match (cp, s2, adrMatchInfoTable:@matchInfo) { scripterror ("re.search is broken.")}; if matchInfo.matchString != "bebe" { scripterror ("re.search is broken.")}}; bundle { //re.extract local { cp; complexLinkPat = "<a[ \t\r\n]*[^>]*href[ \t\r\n]*=[ \t\r\n]*\"?([-_~%@:/\\.A-Za-z0-9]+)\"?[^>]*>([^<]*)"; simpleLinkPat = "<a[ \t\r\n]+[^>]*href[ \t\r\n]*=[ \t\r\n]*\"([^\"]*)\"[^>]*>([^<]*)"; s = string (re.testing.data.html); theList}; cp = re.compile (simpleLinkPat); theList = re.extract (cp, s, {2,1}); if sizeOf (theList) != 59 { scripterror ("re.extract is broken.")}; if theList[57][1] != "Roget's Thesaurus:" { scripterror ("re.extract is broken.")}; if theList[57][2] != "http://www2.thesaurus.com/thesaurus/" { scripterror ("re.extract is broken.")}; cp = re.compile (simpleLinkPat); theList = re.extract (cp, s, {2,1}); if sizeOf (theList) != 59 { scripterror ("re.extract is broken.")}; if theList[25][1] != "FileMaker" { scripterror ("re.extract is broken.")}; if theList[25][2] != "http://www.scripting.com/apps/filemaker.html" { scripterror ("re.extract is broken.")}}; bundle { //re.grep local (cp); local (theList = {"aa", "aab", "a", "ab", ""}); local (s = "aa\raab\ra\rab\r\r"); cp = re.compile ("^aa"); if re.grep (cp, theList) != {"aa", "aab"} { scripterror ("re.grep is broken.")}; if re.grep (cp, s) != {"aa", "aab"} { scripterror ("re.grep is broken.")}; if re.grep (cp, theList, flIncludeMatches:false) != {"a", "ab", ""} { scripterror ("re.grep is broken.")}; if re.grep (cp, s, flIncludeMatches:false) != {"a", "ab", ""} { scripterror ("re.grep is broken.")}}; bundle { //re.join local (listA = {"a", "b", "c"}, listB = {"abcd", "", "efgh", ""}); if re.join ("|", listA) != "a|b|c" { scripterror ("re.join is broken.")}; if re.join ("", listA) != "abc" { scripterror ("re.join is broken.")}; if re.join ("+/+", listB) != "abcd+/++/+efgh+/+" { scripterror ("re.join is broken.")}}; bundle { //re.split local (cp); local (s = "<title>test</title>\r<body>\rtest body\r</body>"); cp = re.compile ("<[^>]*>"); if re.split (cp, s) != {"", "test", "\r", "\rtest body\r", ""} { scripterror ("re.split is broken.")}; if re.split (cp, s, maxSplits:4) != {"", "test", "\r", "\rtest body\r</body>"} { scripterror ("re.split is broken.")}; cp = re.compile ("(<[^>]*>)"); if re.split (cp, s) != {"", "<title>", "test", "</title>", "\r", "<body>", "\rtest body\r", "</body>", ""} { scripterror ("re.split is broken.")}; if re.split (cp, s, maxSplits:3) != {"", "<title>", "test", "</title>", "\r<body>\rtest body\r</body>"} { scripterror ("re.split is broken.")}; local (s2 = "aBcDeFg"); cp = re.compile ("[a-z]+", flCaseSensitive:true); if re.split (cp, s2) != {"", "B", "D", "F", ""} { scripterror ("re.split is broken.")}; cp = re.compile ("[^a-z]+", flCaseSensitive:true); if re.split (cp, s2) != {"a", "c", "e", "g"} { scripterror ("re.split is broken.")}; cp = re.compile ("[A-Z]+", flCaseSensitive:true); if re.split (cp, s2) != {"a", "c", "e", "g"} { scripterror ("re.split is broken.")}; cp = re.compile ("[^A-Z]+", flCaseSensitive:true); if re.split (cp, s2) != {"", "B", "D", "F", ""} { scripterror ("re.split is broken.")}}; bundle { //re.replace local (cp, ct); local (s = "To be or not to be", s2); cp = re.compile ("(be)"); s = re.replace (cp, "\\1BOP", s); if s != "To beBOP or not to beBOP" { scripterror ("re.replace is broken")}; cp = re.compile ("(be)(bop)", flCaseSensitive:false); s = re.replace (cp, "\\2\\1", s); if s != "To BOPbe or not to BOPbe" { scripterror ("re.replace is broken")}; cp = re.compile ("(BOP)(be)"); s = re.replace (cp, "\\2\\1", s, maxReplacements:1); if s != "To beBOP or not to BOPbe" { scripterror ("re.replace is broken")}; cp = re.compile ("(BOP)(be)"); s = re.replace (cp, "\\2\\1", s, adrReplacementCount:@ct); if s != "To beBOP or not to beBOP" { scripterror ("re.replace is broken")}; if ct != 1 { scripterror ("re.replace is broken")}; local (test = "Check http://www.muppets.com/~gonzo/ for more info, send your q's to mailto:go...@mu...."); local (result = "Check <A HREF=\"http://www.muppets.com/~gonzo/\">http://www.muppets.com/~gonzo/</A> for more info, send your q's to <A HREF=\"mailto:go...@mu...\">mailto:go...@mu...</A>."); cp = re.compile ("(http|mailto)(:[/]*[A-Za-z0-9]+[-_~%@:/\\.A-Za-z0-9]+[A-Za-z/0-9])"); test = re.replace (cp, "<A HREF=\"\\1\\2\">\\0</A>", test); if test != result { scripterror ("re.replace is broken.")}}; bundle { //re.visit local (hits = 0); local (test = " <A href ='index.html' > <A href= 'index2.html' > "); on testCallback (adrTable) { case ++hits { 1 { if adrTable^.matchOffset != 2 { scripterror ("re.visit is broken.")}; if adrTable^.matchLength != 25 { scripterror ("re.visit is broken.")}; if adrTable^.matchString != "<A href ='index.html' >" { scripterror ("re.visit is broken.")}}; 2 { if adrTable^.matchOffset != 28 { scripterror ("re.visit is broken.")}; if adrTable^.matchLength != 33 { scripterror ("re.visit is broken.")}; if adrTable^.matchString != "<A href= 'index2.html' >" { scripterror ("re.visit is broken.")}}} else { scripterror ("re.visit is broken.")}; return (true)}; local (cp = re.compile ("<([^>]+)>")); re.visit (cp, test, @testCallback); if hits != 2 { scripterror ("re.visit is broken.")}}; bundle { //re.expand local (pat, mi); pat = re.compile ("(?P<date>(?P<year>(\\d\\d)?\\d\\d)-(?P<month>\\d\\d)-(?P<day>\\d\\d))", flAutoCapture:false); if re.match (pat, "2003-05-30", adrMatchInfoTable:@mi, flMakeGroups:true, flMakeNamedGroups:true) { if re.expand ("\\g<day>.\\g<month>.\\g<year>", @mi) != "30.05.2003" { scripterror ("re.expand is broken")}; if re.expand ("\\g<4>.\\g<3>.\\g<2>", @mi) != "30.05.2003" { scripterror ("re.expand is broken")}; if re.expand ("\\4.\\3.\\2", @mi) != "30.05.2003" { scripterror ("re.expand is broken")}}}}; dialog.notify ("No problems found.") \ No newline at end of file Index: match =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/match,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** match 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- match 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.match ! local (patternRef); patternRef = re.compile ("([a-z]+)"); dialog.notify (re.match (patternRef, "Hello World!")) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.match ! local (matchInfo, sr); sr = re.match (re.compile ("[a-zA-Z]+[0-9]+"), "a123four", adrMatchInfoTable: @matchInfo); dialog.notify (sr); sr = re.match (re.compile ("[0-9]+"), "a 123 four", adrMatchInfoTable: @matchInfo); dialog.notify (sr); sr = re.match (re.compile ("(be){1,2}"), "bebe bop", adrMatchInfoTable: @matchInfo); dialog.notify (sr); sr = re.match (re.compile ("(bo){1,2}"), "be bobop", adrMatchInfoTable: @matchInfo); dialog.notify (sr); sr = re.match (re.compile ("([a-z]+)"), "Hello World!"); dialog.notify (sr) \ No newline at end of file Index: replace =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/re/testing/replace,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** replace 26 Mar 2005 19:43:25 -0000 1.1.1.1 --- replace 7 Aug 2005 23:16:20 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.replace ! local (patternRef, ct); ÇpatternRef = re.compile ("(a|(z))(bc)") patternRef = re.compile ("\\b"); dialog.notify (re.replace (patternRef, "x", "1abc abc1")); local (test = "To be or not to be"); patternRef = re.compile ("be"); test = re.replace (patternRef, "bebop", test); dialog.notify (test); patternRef = re.compile ("(be)(bop)"); test = re.replace (patternRef, "\\2\\1", test, adrReplacementCount:@ct); dialog.notify (test + cr + "(" + ct + " replacements made)") \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.re.testing.replace ! local (cp, ct, test = "To be or not to be"); Çcp = re.compile ("(a|(z))(bc)") cp = re.compile ("\\b"); dialog.notify (re.replace (cp, "x", "1abc abc1")); cp = re.compile ("be"); test = re.replace (cp, "bebop", test); dialog.notify (test); cp = re.compile ("(be)(bop)"); test = re.replace (cp, "\\2\\1", test, adrReplacementCount: @ct); dialog.notify (test + cr + "(" + ct + " replacements made)") \ No newline at end of file |