Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello. I have some address data and I'd like to derive the country based on whether there's a UK postcode in the data. So if the value in the postcode column is one of these formats then I want to assume that the country is UK
An nAA
Ann nAA
AAn nAA
AAnn nAA
AnA nAA
AAnA nAA
A=Alpha character
n=numeric character
Is it possible to do that in tMap?
Thank you!
you might have postcode null in input
try
(row1.Postcode != null) && row1.Postcode.matches ("^[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}$") ? "GB" : null
That's really helpful, thank you. But how would I put this into the tMap expression? I tried this:
row1.Postcode.matches ("^[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}$") ? "GB" : null
So I'm saying if the postcode matches the pattern, then set the value to GB, else null but it doesn't seem to like that. It produces a java.lang.NullPointerException error.
you might have postcode null in input
try
(row1.Postcode != null) && row1.Postcode.matches ("^[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}$") ? "GB" : null
Perfect, that worked thanks!