Removing Values after the 5 Digits Zip Code

Hi Community

I want to keep only the first five digits of the ZipCode while removing the remaining digits
As you can see on the right side of the following screenshot. Can anyone help with this? Thanks
image

Hi,

Can you try the following expression?

image

System.Text.RegularExpressions.Regex.Replace(yourString,"-\d+$","")

Regards,

Hi @Sisay_Dinku,

Here is a sample workflow. SplitZipCode.xaml (6.5 KB)

Hope that helps !

Regards,
Nithin

Hi @Yoichi
Thanks a lot!
Yes, the expression works. Here is what I’d like to do. I want the Zip Code column to be replaced with the new 5 digits. Can you show me how the flow would go to achieve that?
Remove_four_Digit_From_ZIP.xlsx (9.9 KB)
Please see this attached excel file. Thanks

@Yoichi , I use modern design. Thanks!

Hello

You can it in multiple ways. 2 methods provided below.

1)By using the regex expression:
System.Text.RegularExpressions.Regex.Match(SampleString,“(\d{5})”).ToString

2)By using the Split method
SampleString.Split(“-”)(0)

Attached the workflow also for your reference.


Demo10.zip (136.1 KB)

Thanks

HI @Sisay_Dinku

Try with this expression

System.Text.RegularExpressions.Regex.Match(CurrentRow("Postal Code").ToString.Trim,"^\d+").ToString

Check out this XAML file

ForEachRow.xaml (12.5 KB)

image

Regards
Gokul

Hi,

Here you are.

Sample20221201-5.zip (10.4 KB)

Regards,

@Yoichi works fine. Thanks a lot for but the Zip code led by 0, zero gets dropped. I want to keep it.
image

HI @Sisay_Dinku

You can ry with Workbook Write range activity

Check out this XAML file

ForEachRow.xaml (14.3 KB)

image

Output snap


t

Hi,

It’s because excel identify this data as numeric.
Can you try to set these cells as text manually in advance?
Or add FormatCell activity as the following?

Sample20221201-5v2.zip (10.6 KB)

Regards,

Hello @Yoichi, that worked perfectly fine for me. Thanks a lot!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.