adding findString()
This commit is contained in:
parent
adce03b134
commit
8582e1b064
1 changed files with 12 additions and 0 deletions
|
@ -4,6 +4,18 @@
|
|||
import re
|
||||
|
||||
|
||||
def findRegexp(string, regexp):
|
||||
result = None
|
||||
try:
|
||||
regexp = re.compile(regexp)
|
||||
match = regexp.search(string)
|
||||
if match:
|
||||
result = match.group(1)
|
||||
return result
|
||||
|
||||
def findString(string, string0, string1):
|
||||
return findRegexp(string, re.escape(string0) + '(.*?)' + re.escape(string1))
|
||||
|
||||
# Capitalizes the first letter of a string.
|
||||
capfirst = lambda x: x and x[0].upper() + x[1:]
|
||||
|
||||
|
|
Loading…
Reference in a new issue