Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
those regexes are killing me
marcussteiner
Hi all,
I need some help with a filter and substitution. We have custom dcr's which go straight into the database. For one filed we've got three possible values which i'd like to catch using a subsitition. The value can be either "true" then replace it with 1 it can be false then replace it with 0 but for all other possibilities change it to 4. I just don't get the b...dy regex up and running. Any ideas?
Thanks
<field name="data-record/0/homepage/0" match="true" replace="1" />
<field name="data-record/0/homepage/0" match="false" replace="0" />
<field name="data-record/0/homepage/0" match="[^(true|false)]" replace="4" />
Find more posts tagged with
Comments
Adam Stoller
I'm not sure if there is a way to provide a negative regex in the config files like this (what you tried wouldn't work anyway) - but depending on how the processing is done, you might be able to use a 'default' like:
<field name="data-record/0/homepage/0" match=".*" replace="4" />
<field name="data-record/0/homepage/0" match="true" replace="1" />
<field name="data-record/0/homepage/0" match="false" replace="0" />
The above is
untested
and it's possible that
".*"
should be just
"*"
depending on the regex library being used -
and
this presupposes that it will continue processing the field of data
after
having already found a match - so that the value will be set to 4 by default and then
changed
to 1 if "true" or 0 if "false". If the processing of the field stops at the first successful match - then they will all be set to 4 regardless of what value exists. If that's the case - simply move the line I put at the top to the bottom and it should do what you want ... I think.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com