From 8582e1b064ff422088292241d33355f55402e4e1 Mon Sep 17 00:00:00 2001 From: Rolux Date: Tue, 29 Apr 2008 13:26:42 +0200 Subject: [PATCH] adding findString() --- oxutils/text.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/oxutils/text.py b/oxutils/text.py index 79a553a..90b0b1d 100644 --- a/oxutils/text.py +++ b/oxutils/text.py @@ -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:]