adding findString()

This commit is contained in:
Rolux 2008-04-29 13:26:42 +02:00
parent adce03b134
commit 8582e1b064

View file

@ -4,6 +4,18 @@
import re 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. # Capitalizes the first letter of a string.
capfirst = lambda x: x and x[0].upper() + x[1:] capfirst = lambda x: x and x[0].upper() + x[1:]