PDA

View Full Version : Using REG_REPLACE



JSenecal
Apr 26th, '07, 08:39 AM
I use regular expressions on a regular basis and I checked java regular expressions to make sure they weren't different from what I was used to. But when I tried using the REG_REPLACE tag in an export template, the tags showed up in the exported html.

I put the following into my export template:

<!--REG_REPLACE--><!--REGSTRING>(.*)/.*<!--/REGSTRING><!--REPSTRING>\1<!--/REPSTRING><!--CAMPAIGN_USE--><!--/REG_REPLACE>

I thought this would have stripped off a slash and all following text from the CAMPAIGN_USE field. But all that happened was the CAMPAIGN_USE was filled in:

<!--REG_REPLACE--><!--REGSTRING>(.*)/.*<!--/REGSTRING><!--REPSTRING>\1<!--/REPSTRING>23 July 1977/Testing/Test<!--/REG_REPLACE>

What am I doing wrong?

Simon
Apr 26th, '07, 09:37 AM
You're not entering the tags correctly. It's not "<!--REGSTRING>", it's "<!--REGSTRING-->" (same goes for REPSTRING and the ending tags).

JSenecal
Apr 26th, '07, 10:05 AM
I doubled checked, and the tags are listed incorrectly in the documentation. I had done a copy and paste to get them in the first place. This is my first time playing with export templates, so I hadn't noticed the difference.

Once I fixed the tags they worked and did a global search and replace of the entire template.

Is there any way to limit the search and replace to be just the contents of the REG_REPLACE container?

Alternativly, can I have more than one REG_REPLACE container and have each of them performed over the entire file?

Simon
Apr 26th, '07, 10:07 AM
I doubled checked, and the tags are listed incorrectly in the documentation. I had done a copy and paste to get them in the first place. This is my first time playing with export templates, so I hadn't noticed the difference.

Once I fixed the tags they worked and did a global search and replace of the entire template.
I'll get the docs corrected.


Is there any way to limit the search and replace to be just the contents of the REG_REPLACE container?
No, the REG_REPLACE will operate over the entire document (by design).


Alternativly, can I have more than one REG_REPLACE container and have each of them performed over the entire file?Yup, you can have as many of the little buggers as you like ;)

JSenecal
Apr 26th, '07, 10:10 AM
That works for me. I can include my own tags to limit the search to just the area I want to focus on, then strip out those tags as part of the replace.

Thanks!

rjcurrie
Apr 26th, '07, 01:49 PM
Oops. My bad. I have sent Dan corrected docs that fix the missing "--" problem discussed here and a couple of others.