It is a question of finding and returning the address of the lot number and road name by Python regular expression.

Asked 2 years ago, Updated 2 years ago, 83 views

For example, in the sentence 'I live in 338 Samseong-dong, Yongsan-gu, Seoul'

I'm going to solve the problem of finding '338 Samseong-dong, Yongsan-gu, Seoul'.

You should be able to find it with a street name address I'm worried because I have to find some empty addresses.

I'm going to search for the street name address and lot number address at the same time

regex = r'(\w+[City, Province]\s*)?(\w+[Old, City, County]\s*?(\w+[Old, City]\s*)?(\w+[Myeon, Eup]\s*)?(\w+\d*\w*[Dong, ri, ro, road]\s*)?(\w*\d+-?\d*)?'

You entered the regex variable in the form of

test = 'I live in 338 Samseong-dong, Yongsan-gu, Seoul'

After you type

x = re.search(regex, test) x.group() If you do this

``This is the result.

test = 'I live in 338 Samseong-dong, Yongsan-gu, Seoul'

If you proceed to , you will find the address exactly address.

I think all the regular expressions in regex are optionally given as ?, so the first value you look for is blank, but I don't know how to exclude it. What should I do?

python regex

2022-09-22 20:12

1 Answers

If you have to cover those various cases, it would be better to use the search engine.

I think we need to separate the lights.If so, you need to do morpheme analysis.

When you say, "I live at 338 Samseong-dong, Yongsan-gu, Seoul," you should remove "at" or "at 338" in Seoul Metropolitan Government and extract search terms focusing on nouns.


2022-09-22 20:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.