Project

General

Profile

« Previous | Next » 

Revision 1680

strings.py: Added with_prefixes()

View differences:

lib/strings.py
16 16
    if str_.startswith(prefix): return str_[len(prefix):]
17 17
    else: return str_
18 18

  
19
def remove_prefixes(prefixes, str_):
20
    for prefix in prefixes: str_ = remove_prefix(prefix, str_)
21
    return str_
22

  
23
def with_prefixes(prefixes, str_): return (p+str_ for p in prefixes)
24

  
19 25
def remove_suffix(suffix, str_):
20 26
    if str_.endswith(suffix): return str_[:-len(suffix)]
21 27
    else: return str_
22 28

  
23
def remove_prefixes(prefixes, str_):
24
    for prefix in prefixes: str_ = remove_prefix(prefix, str_)
25
    return str_
26

  
27 29
def overlaps(str0, str1): return str0.find(str1) >= 0 or str1.find(str0) >= 0
28 30

  
29 31
##### Unicode

Also available in: Unified diff