re.findall(a patern,'function(dsf sdf sdf)')
gcmartijn at gmail.com
gcmartijn at gmail.com
Sat Jul 26 06:03:51 EDT 2008
H!
First I have some random string below.
bla = """ <script type="text/javascript">
// <![CDATA[
var bla = new Blaobject("argh 1a", "argh 2a", "24", 24, 345)
function la( tec )
{
etc etc
}
function other thing( ){
var two = new BlaObject("argh 1b", "argh 2b", ""+(sv), ""+(2f),
"4");
bla die bla
}
// ]]>
</script> """
Now I'm trying to get each BlaObject with the first (variable)
function argument
And I can say that this isn't working
for a in re.findall(r'([BlaObject ])(.*)([)] *)',bla):
print a
The output must be something like:
# ('BlaObject','argh 1a')
# ('BlaObject','argh 1a')
or
# Blaobject("argh 1a", "argh 2a", "24", 24, 345)
# BlaObject("argh 1b", "argh 2b", ""+(sv), ""+(2f), "4");
My simple idea was to
a. the start position is the BlaObject
b. the stop position is the character ) (not ); because its a
javascript function)
c. the output [a (everything between) b]
Who knows the answer ?
Thanks very much,
GCMartijn
More information about the Python-list
mailing list