Материал из Википедии — свободной энциклопедии
def RBR(a,b):
return a.lower()==b.lower()
def RBRm(a,b):
for b1 in b:
if a.lower()==b1.lower():
return 1
return 0
def perv_upper(t):
if len(t)<1:
return u''
return t[0].upper()+t[1:]
def perv_lower(t):
if len(t)<1:
return u''
return t[0].lower()+t[1:]
def perv_lower_s(s):
r=[]
for t in s:
r.append(perv_lower(t))
return r
def iskat(t,s):
lt=len(t)
ls=len(s)
i=0
while i<=lt-ls:
if t[i:i+ls]==s:
return i
i+=1
return -1
def iskats(t,i,s):
lt=len(t)
ls=len(s)
while i<=lt-ls:
if t[i:i+ls]==s:
return i
i+=1
return -1
def iskato(t,i,s):
ls=len(s)
while i>=0:
if t[i:i+ls]==s:
return i
i-=1
return -1
def iskats_mn(t,p0,ss):
i=p0
while i<len(t):
for j in range(len(ss)):
if t[i:].startswith(ss[j]):
return (i,j)
i+=1
return (-1,0)
def iskkonpodp(t,i,os,zs):
j=0
while i<len(t):
if t[i:].startswith(os):
j+=1
i+=len(os)
continue
elif t[i:].startswith(zs):
j-=1
if j==-1:
return i
i+=len(zs)
continue
i+=1
return -1
def ubr_nk_prob(t):
i=0
while i<len(t) and ((t[i]==u' ') or (t[i]==u'\n') or (t[i]==u'\t') or
(t[i]==u'\r')):
i+=1
j=len(t)-1
while j>i and ((t[j]==u' ') or (t[j]==u'\n') or (t[j]==u'\t') or
(t[j]==u'\r')):
j-=1
return t[i:j+1]
def spisvstr(s,ra):
t=u''
fp=0
for a in s:
if fp:
t+=ra
t+=a
fp=1
return t