Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: dhrobertsonHi all,
I have a string field that has had the postcode embedded in it. I need to extract the postcode in order to make it into a new field. most of the fields have the same pattern, however, 1 field doesn't follow that format (CO. Londonderry). I have copied what I have done to get around the issue, but I'm wondering whether there is a neater way and more predictable way for doing this? it is fine if every time the postcode is at the end, but possible they decide to do something silly and it is not at the end which would mean my scripts wouldn't work. It would be great if there was some sort of pattern function that could find the pattern of a postcode and extract that, but I don't think there is anything like that for the fields themselves. I know there is something for the column names but I don't think there is anything for the fields...
anyway. here is what I have. if anyone has a better solution, please let me know?
node:Static_Data
bretype:core::Static Data
editor:sortkey=54622dfc3f1d7e9c
output:@40fe6c55598828e5/=
prop:StaticData=<<EOX
Account Name:string
APPLE PARK LH9 7HT
PEAR CITY LT95 6RT
NTH WEST CO. LONDONDERRY
ORANGE TOWN GT5 4RD
EOX
editor:XY=160,50
end:Static_Data
node:Filter
bretype:core::Filter
editor:sortkey=54622e222a756481
input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
output:@40fd2c7420761db6/=
prop:Script=<<EOX
temp_postcode = 'Account Name'.right(15)
postcode = ltrim(if toUpper(temp_postcode) == "CO. LONDONDERRY" then temp_postcode else temp_postcode.right(8))
emit 'Account Name',postcode
EOX
editor:XY=300,50
end:Filter