Extract Address from String with RegEx

@Charbel1

Hey everyone,

I have e question I want to extract a address from a string like:

name
rode 12
12354 USA

text text text text text

result:
name
rode 12
12354 USA

Is it possible to do this I looked in the Forum and in the Internet but nobody have a good solution for this I find out the RegEx is not the best way for that but I can’t find a different way. Maybe someone have a solution for that.

thanks for your help.

Hi,

Is there any rule to find address?

For example, 5 digit zip code always exists at the beginning of last line. There are 2 or more linebreaks after address etc.

Regards,

Hey,
yes the 5 digit zip code is always there with the city like:

12345 Berlin

and the street and the house number is also always there like:

street 132

is that wat you mean? @Yoichi

Hi @uandi_ks

Does it contain any constant header like address?

Regards
Gokul

Hi,

Thank you for your reply.
How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(.+\n)+\d{5}.*").Value

Sequence.xaml (5.8 KB)

Regards,

1 Like

Sorry now that’s the problem I need to extract it out of a text.

that’s wat i’m luking for. Is it posible in Regex to ignore words becose i wont to ignore my personal address.

You need to extract only the about text, its correct?
@uandi_ks

Regards
Gokul

Correct but in the Text is my address and this address and I need this won. If I do this with regex I need to Ignore my address.

Hi,

As it will be complicated to exclude your address using regex, any other way (such as If activity with String.Contains) is better, I think.

And does your data have multiple addresses in single string? If so, the following is better.

mc = System.Text.RegularExpressions.Regex.Matches(yourString,"([^\r\n]+\r?\n)+\d{5}.*")

Then filter out your address from mc.

note: mc is MatchCollection

Regards,

Thanks I think that will work.

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