Re: reg exp and removing all data between two strings
Summer <crazysummer2004-/[email protected]> Mon, 1 Jul 2013 19:05:23 -0700 (PDT)
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <[email protected]> |
Thanks Larry - I tried it, and just can't get it to work. Man, this is rough! lol Thanks though. ________________________________ From: Larry Leszczynski <[email protected]> To: [email protected] Sent: Monday, July 1, 2013 5:37 PM Subject: Re: [Templates] reg exp and removing all data between two strings Hi Summer - > I want to omit the tags and everything in between. > > > [% customBlock = BLOCK; > '<customTag>'; > A BUNCH OF TT STUFF > '</customTag>' > %] > > [% > newString = customBLOCK.replace("(?i:<customTag>[.*?]</customTag>)",""); > %] First, I think to do the case-insensitive matching you need to have "(?i)" at the front - note the surrounding parens. Second, anything in square brackets like "[...]" means you are trying to match a range of characters, so in this case it thinks you want to match a single character that is either a period, an asterisk, or a question mark. Not tested, but you might need something like: newString = customBLOCK.replace("(?i)<customTag>.*?</customTag>", ""); HTH, Larry _______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates _______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates