uandi_ks
(Kstukemeier)
October 6, 2021, 9:06pm
1
@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.
Yoichi
(Yoichi)
October 6, 2021, 11:07pm
2
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,
uandi_ks
(Kstukemeier)
October 7, 2021, 7:33am
3
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
Gokul001
(Gokul Balaji)
October 7, 2021, 7:38am
4
Hi @uandi_ks
uandi_ks:
name
rode 12
12354 USA
Does it contain any constant header like address?
Regards
Gokul
Yoichi
(Yoichi)
October 7, 2021, 7:41am
5
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
uandi_ks
(Kstukemeier)
October 7, 2021, 7:42am
6
Sorry now that’s the problem I need to extract it out of a text.
uandi_ks
(Kstukemeier)
October 7, 2021, 7:55am
7
that’s wat i’m luking for. Is it posible in Regex to ignore words becose i wont to ignore my personal address.
Gokul001
(Gokul Balaji)
October 7, 2021, 8:00am
8
uandi_ks:
name
rode 12
12354 USA
You need to extract only the about text, its correct?
@uandi_ks
Regards
Gokul
uandi_ks
(Kstukemeier)
October 7, 2021, 8:04am
9
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.
Yoichi
(Yoichi)
October 7, 2021, 8:10am
10
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,
uandi_ks
(Kstukemeier)
October 7, 2021, 8:18am
11
Thanks I think that will work.
system
(system)
Closed
October 10, 2021, 8:18am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.