This project is read-only.


Transform Data


Just wondering what i'm doing wrong here, i want to translate the subnet to a subnetmask like:
24 -
So i created the XML file like (see attachment)
But when the subnet is like 24, i get a result what is not as aspected, it looks like the subnet is split into 2 and 4 so it gets all the subnets where a 2 is in the number and all subnets with a 2 in it.
help ?

file attachments

Closed Oct 1, 2012 at 7:17 AM by jfanjoy
Resolved by user education.


jfanjoy wrote Sep 30, 2012 at 12:46 AM

The problem is that you are performing multiple replacements against the same data. it does not apply all the replacements as "OR" conditions but rather it applies each replace against the current data.

So if you use a subnet of "24", then what happens is it attempts to process the replacements for 8 through 23 with no matches then when it processes "24", it replaces the string "24" with the string "". When it then subsequently applies the replace for "25", it replaces each "25" in "" with "" so you end up with a string like "" which then continues to get processed and additional replacements happen with it hits the replace for "28" etc.

My recommendation would be to use the RegEx method so you can clearly control exactly what you want searched for and replaced.

I've modified your XML with a version that should accomplish what you're after. What I did was first apply a "Trim" transform to ensure there are no leading or trailing spaces, then I changed all the replace transforms so that they use regular expression and wrapped each searchstring in ^ and $ which mean start of string and end of string respectively so that when you do a regex search for ^24$ you will only get a match if "24" is the entire string.

Vrakking wrote Oct 1, 2012 at 6:38 AM

Thanks, this was just the kind of help i was looking for, not only did you explaine what i was doing wrong, but you also gave me the solution (and more Method="RegEx") to handle this kind of usage in the future !

wrote Oct 1, 2012 at 7:17 AM

wrote Feb 14, 2013 at 7:31 PM

wrote May 16, 2013 at 9:21 AM