re.findall(a patern,'function(dsf sdf sdf)')

gcmartijn at gcmartijn at
Sat Jul 26 12:03:51 CEST 2008


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),

		  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')
# 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,

More information about the Python-list mailing list