Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 8th, 2004, 10:10 PM
deflatormouse deflatormouse is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 26 deflatormouse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Python regex problem

I am making a template parsing program. This part will parse code blocks from the template. It is an iterator that takes the values from a list and prints them how the block says. Much like Smarty PHP template.

Template file:
Code:
<table width="100" border="1" bgcolor="#490903">
{iterate name="i" list="list1"}
<tr><td>{list1[i]}</td></tr>
{/iterate}

</table>

something in between blocks!

<table width="100" border="1" bgcolor="#490903">

{iterate name="i" list="list2"}
<tr><td>{list2[i]}</td></tr>
{/iterate}



My problem is getting the text in between the iterate blocks. I don't know how to fine tune a regex to get just the inbetween stuff. Otherwise it is just removed.

I have tried this to get the between text : \{iterate name=\".*?\" list=\".*?\"\}.*?\{/iterate\}(.*?)\{iterate name=\".*?\" list=\".*?\"\}.*?\{/iterate\}

It works, with re.split, but it gets a bunch of unwanted matches along with the correct ones. Weeding them out isn't working. Is there a way to make a regex to find just what is between {iterate}{/iterate} blocks? Everything I have tried gives unwanted matches.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Python regex problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT