I have a postcode in a string “123 Fake street,Farnham House,Cork,Ireland,T13 KN13” how can i check if the postcode is present in the address and extract it
the post code can be in the format similar to “T13 KN13”
I have a postcode in a string “123 Fake street,Farnham House,Cork,Ireland,T13 KN13” how can i check if the postcode is present in the address and extract it
the post code can be in the format similar to “T13 KN13”
use assign activity
result = system.text.regularexpression.regex.match(your string variable,“[A-Z]{1,}[0-9]{2}”).value
Use the above syntax
it helps!
Hi Usha, I’ve just tried this and had an issue - Compiler Error(s) encountered processing expression “system.text.regularexpression.regex.match(your string variable,“[A-Z]{1,}[0-9]{2}”).value” ‘regularexpression’ is not a member of ‘text’
HI @duaine.b
You can try with this regex pattern
str_input= “123 Fake street,Farnham House,Cork,Ireland,T13 KN13”
str_variable=System.Text.RegularExpressions.Regex.Match(str_input,“\w+\d+\s{0,}\w+\d+”).Value
you can try with this also both will work for you
str_input= “123 Fake street,Farnham House,Cork,Ireland,T13 KN13”
str_input.Split({“,”},StringSplitOptions.RemoveEmptyEntries).Last
System.Text.RegularExpressions.Regex.Match(your string variable,“[A-Z]{1,}[0-9]{2}”).value
try this
you take the fuctions which comes automatically
Hi @Praveen_Mudhiraj This works great but if the post code is now T13 KN9T it doesnt work. would you be able to assist?
you can try it above only…it will work ,
for your reference you can see the output
str_input= “123 Fake street,Farnham House,Cork,Ireland,T13 KN9T”
str_input.Split({“,”},StringSplitOptions.RemoveEmptyEntries).Last
The following regular expression can be used for the purpose of validation:
^[A-Z]{1,2}[0-9][A-Z0-9]? ?[0-9][A-Z]{2}$
The following regular expression can be used for the purpose of validation and includes postcode formats from Special Cases:
^(([A-Z]{1,2}[0-9][A-Z0-9]?|ASCN|STHL|TDCU|BBND|[BFS]IQQ|PCRN|TKCA) ?[0-9][A-Z]{2}|BFPO ?[0-9]{1,4}|(KY[0-9]|MSR|VG|AI)[ -]?[0-9]{4}|[A-Z]{2} ?[0-9]{2}|GE ?CX|GIR ?0A{2}|SAN ?TA1)$
booloutput=system.text.regularexpression.regex.Ismatch(inputstring,“[A-Za-z0-9\s]+$”)
gives you true or false
use if condition based on it you can make next steps
you can find and click on if it is showing error like regex is not a member
cheers
@Praveen_Mudhiraj This entry is System.Text.RegularExpressions.Regex.Match(strAddress,“\w+\d+\s{0,}\w+\d+”).Value work perfectly i made an error in the format for the post code, it should be T13 KN9T. I cannot use T23 KN9T as they may not be a post code in the address
you can try using string split functions.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.