* added str_grep and str_igrep.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $Id: text_tools.py,v 1.3 2010-02-24 14:28:13 wirawan Exp $
|
||||
# $Id: text_tools.py,v 1.4 2010-05-28 18:46:53 wirawan Exp $
|
||||
#
|
||||
# wpylib.text_tools
|
||||
# Created: 20091204
|
||||
@@ -104,6 +104,13 @@ def str_expand(template, params, maxiter=100):
|
||||
return str1
|
||||
|
||||
|
||||
def str_grep(S, strs):
|
||||
return [s for s in strs if s.find(S) >= 0]
|
||||
|
||||
def str_igrep(S, strs):
|
||||
return [i for (s,i) in zip(strs,xrange(len(strs))) if s.find(S) >= 0]
|
||||
|
||||
|
||||
def slice_str(s):
|
||||
return "%s:%s:%s" % (
|
||||
ifelse(s.start == None, "", str(s.start)),
|
||||
|
||||
Reference in New Issue
Block a user