[Zope] Extracting a part of a string
Andreas Jung
Andreas Jung" <andreas@digicool.com
Fri, 29 Jun 2001 10:03:33 -0500
Something like that should work:
import re
reg = re.compile('\(.*\)')
print reg.sub('','some words (another words)')
The regular expression finds all occurences of text between two braces
and replaces then with the empty string.
Andreas
----- Original Message -----
From: sbergmann@weblog.de
To: zope@zope.org
Sent: Friday, June 29, 2001 8:56 AM
Subject: [Zope] Extracting a part of a string
Hello Zopers,
I have the following problem:
I have a string from a database and want to delete a part from the string
and write it back to the database.
An example:
a = ' some words ( another words)'
I want to extract now everything without the brackets themselves anth the
words in the brackets.
That should be the result.
a = 'some words'
How can I do that. With the string-module and "find" I can get the index
where the brackets begin. But there is no function to get the string from
index 0 to the result index of "find".
Is there another way to do this?
I´m sure that somebody has a solution for me.
Steffen