简体   繁体   English

通过asp.net(vb.net)从文本中提取地址数据

[英]Address data extraction from text via asp.net (vb.net)

I have address data that is surrounded by random text. 我的地址数据被随机文本包围。 Is there a way to extract this data either with a call to a web service or some vb.net function? 是否可以通过调用Web服务或某些vb.net函数来提取此数据?

example: 1111 S WILSON ROAD APT B8 CITY STATE 55555 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 示例:1111 S WILSON ROAD APT B8城市州55555 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

If your random data is always 0's, try doing a string.Replace to get rid of the 0's and then a Trim() to get rid of extra spaces. 如果您的随机数据始终为0,请尝试执行一个字符串。替换以去除0,然后使用Trim()去除多余的空格。 You could also use Regex to accomplish the same task to get rid of 0's. 您也可以使用Regex完成相同的任务以摆脱0。

If your random data is truly random, is there a way you can introduce some delimiters in at the beginning and end of your address? 如果您的随机数据是真正的随机数据,是否有办法在地址的开头和结尾引入一些定界符? For instance, you could have: 例如,您可能有:

#1111 S WILSON ROAD APT B8 CITY STATE 55555# 0 0 0 0 0 0 0 0 0 0 0 0 

This way, you could the SubString function to extract just the data you need using those special characters as delimiters. 这样,您可以使用这些特殊字符作为分隔符,使用SubString函数仅提取所需的数据。

-D -D

from your example it looks like your data is delimited with 4 numbers in the beginning and 5 numbers in the end so you can use regex as 从您的示例中看来,您的数据似乎以4个数字开头和5个结尾分隔,因此您可以将regex用作

\d{4}(?<Address>.*)\d{5}

and look for Address group name in match 并查找匹配的地址组名称

Thanks guys for the responses.. I was not fully informed of the test data (.. of course). 谢谢大家的答复..我没有完全了解测试数据(当然。)。 What I ended up doing was tossing the text over to the Yahoo PlaceFinder API. 我最终要做的是将文本扔​​给Yahoo PlaceFinder API。 If it did not return an exact match, I was alert the user and set the address as best I could. 如果没有返回完全匹配的内容,我会提醒用户并将地址设置为最佳。 Again thanks for your help. 再次感谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM