############################################################################
#
# File: noncase.icn
#
# Subject: Procedures for case-independent matching
#
# Author: Robert J. Alexander
#
# Date: May 2, 2001
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# Kit of case-independent versions of Icon's built-in string-analysis
# procedures.
#
############################################################################
procedure c_any(c,s,i1,i2)
return any(c_cset(c),s,i1,i2)
end
procedure c_find(s1,s2,i1,i2)
local scanPos,endPos
scanPos := match("",s2,i1,i2)
endPos := many(&cset,s2,i1,i2) | scanPos
suspend scanPos - 1 + find(map(s1),
map((if \s2 then s2 else &subject)[scanPos:endPos]))
end
procedure c_many(c,s,i1,i2)
return many(c_cset(c),s,i1,i2)
end
procedure c_match(s1,s2,i1,i2)
local scanPos,endPos
scanPos := match("",s2,i1,i2)
endPos := scanPos + *s1
return (map(s1) == map((if \s2 then s2 else &subject)[scanPos:endPos]),endPos)
end
procedure c_upto(c,s,i1,i2)
suspend upto(c_cset(c),s,i1,i2)
end
procedure c_cset(c)
static lstring,ustring
initial {
lstring := string(&lcase)
ustring := string(&ucase)
}
return cset(map(c) || map(c,lstring,ustring))
end
This page produced by UniDoc on 2021/04/15 @ 23:59:44.