From f014904704e02fde015d786d5200d306a4195d73 Mon Sep 17 00:00:00 2001 From: Rolux Date: Tue, 29 Apr 2008 15:17:10 +0200 Subject: [PATCH] fixing findRegexp() --- oxutils/text.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/oxutils/text.py b/oxutils/text.py index 8c54a3d..eeaa526 100644 --- a/oxutils/text.py +++ b/oxutils/text.py @@ -5,18 +5,21 @@ import re def findRegexp(string, regexp): - return re.compile(regexp, re.DOTALL).findall(string) + result = re.compile(regexp, re.DOTALL).findall(string) + if result: + return result[0].strip() + return None def findString(string, string0, string1 = ''): - string0 = re.escape(string0) + if string0: + string0 = re.escape(string0) + else: + string0 = '^' if string1: string1 = re.escape(string1) else: string1 = '$' - result = findRegexp(string, string0 + '(.*?)' + string1) - if result: - return result[0].strip() - return None + return findRegexp(string, string0 + '(.*?)' + string1) # Capitalizes the first letter of a string. capfirst = lambda x: x and x[0].upper() + x[1:]