以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 【已解决】[求助]收货地址解析这个可以用在狐表上吗? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=154391) |
-- 作者:zto001 -- 发布时间:2020/9/13 21:14:00 -- 【已解决】[求助]收货地址解析这个可以用在狐表上吗? https://blog.csdn.net/jackbon8/article/details/107958832?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-19-107958832.nonecase&utm_term=%E6%94%B6%E8%B4%A7%E5%9C%B0%E5%9D%80%E8%A7%A3%E6%9E%90 [求助]这个可以用在狐表上吗?
[此贴子已经被作者于2020/11/23 0:53:09编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/9/13 21:52:00 -- 不能。如果要拆分数据,有规律的可以参考: http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=85241 http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=78633
|
-- 作者:zto001 -- 发布时间:2020/9/14 1:31:00 -- Dim pattern As String = "[1][358][0-9]{9}|[0][0-9]{2,3}-[0-9]{7,8}" Dim 收货信息= "湖南省长沙市浏阳市浏阳大道阿斯事部 15616161616 某某" Dim 省,市,区,地址,电话,姓名 As String Dim 解析后 As String=收货信息 \'【解析剥离电话号码】 Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) For Each match As System.Text.RegularExpressions.Match In rgx.Matches(收货信息) 电话=match.Value 解析后=解析后.Replace(match.Value ,"") Next \'Output.Show(解析后) \'【解析剥离省市区地址】 Dim p As String = "([省市区县乡镇村])" Dim p2 As String = "([省市区县乡镇村]|街道|街)" Dim r As New System.Text.RegularExpressions.Regex(p) Dim str = r.Split(解析后) Dim Int As Integer For Each a As String In str int=int+1 Select Case int Case 1 省=a Case 2 省=省 & a Case 3 市=a Case 4 市= 市 & a Case 5 区=a Case 6 区=区 & a Case Else 地址=地址 & a End Select Next Output.Show(省) Output.Show(市) Output.Show(区) Output.Show(地址) Output.Show(电话) 勉强可以凑合下解析出省市区电话。有两个问题 1、如果省市区地址不规范,导致没有int没有那么多位,会出错(如地址是长沙市浏阳市浏阳大道阿斯事部 15616161616 某某),应该怎样改好点(不出错,最好是如果少了省份,省为空值) 2、省份有自治区、特别行政区、这两个怎么分出来? 3、姓名怎么分出来
[此贴子已经被作者于2020/9/14 1:31:28编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/9/14 8:42:00 -- 程序只能处理规范的数据。特殊省份可以考虑直接处理,比如判断地址包含特殊省份名称,另外处理。 姓名没有办法区分。如果统一在电话号码之后,可以去取电话字符后的内容作为名称
|
-- 作者:zto001 -- 发布时间:2020/9/14 10:36:00 -- 验证中文姓bai名的正则表达du式:[\\u4e00-\\u9fa5],这个表达式是专门用来匹配中文姓名的。zhi 用这个正则试试。 一段文本里一般用 ,;/ 空格等符号或者电话号码 断开 的,一般在两字以上五字以内 怎么写?
[此贴子已经被作者于2020/9/14 10:36:58编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/9/14 10:44:00 -- Dim s As String = "如地址是长沙市浏阳市浏阳大道阿斯事部 15616161616 某某" Dim arr() As String = s.split(new Char(){",",";","/"," "}) msgbox(arr.length) msgbox(arr(2))
|
-- 作者:zto001 -- 发布时间:2020/9/14 12:40:00 -- https://blog.csdn.net/zl544434558/article/details/45331213 这个代码怎么改? 1、姓名输入框不允许为空 2、姓名输入框只能输入汉字且长度为2-4 3、姓名输入框的姓只能是百家姓里面 Dim s As String = "如,地址 是长沙;市浏阳市/浏阳大道阿 斯事部斯事部 斯事部斯事部是 斯事部斯事部是的 斯事部斯事部是试试 15616161616 某某 李佳琪" Dim arr() As String = s.split(new Char(){",",";","/"," "}) For Each ar As String In arr 使用正则表达式判断是否有姓名 Next |
-- 作者:zto001 -- 发布时间:2020/9/14 12:55:00 -- Dim s0 As String = ar Dim p As String = "\\w*[\\u4e00-\\u9fa5]{2,4}\\w*" 正则表达式判断是否是2-4字汉字 "^[李]+\\w这个是正则表达式开头以李开头的,如何把两个正则表达式合在一起 Dim rgx = new System.Text.RegularExpressions.Regex(p, System.Text.RegularExpressions.RegexOptions.IgnoreCase) If rgx.isMatch(s0) Then Output.Show("匹配") Else Output.Show("不匹配") End If |
-- 作者:zto001 -- 发布时间:2020/9/14 13:14:00 -- \'\'\' Dim s As String = "李如,柳址 诸葛长沙;市浏阳市/浏阳大道阿 斯事部斯事部 斯事部斯事部是 斯事部斯事部是的 斯事部斯事部是试试 15616161616 某某 李佳琪" Dim arr() As String = s.split(new Char(){",",";","/"," ","0","1","2","3","4","5","6","7","8","9","|",",","。",";",":"}) For Each ar As String In arr \' \'msgbox(arr.length) \'msgbox(arr(2)) Dim s0 As String = ar Dim p As String = "^[赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯昝管卢莫经房裘缪干解应宗丁宣贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄麴家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘景詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲邰从鄂索咸籍赖卓蔺屠蒙池乔阴欎胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍舄璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庾终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查後荆红游竺权逯盖益桓公上欧赫皇尉澹淳太轩令宇长鲜闾亓仉督子颛端漆壤拓夹晋楚闫法汝鄢涂钦百南呼归海微岳帅缑亢况后有琴西商牟佘佴伯赏墨哈谯笪年爱阳佟第言福姓]+\\w*[\\u4e00-\\u9fa5]{1,4}\\w*" Dim rgx = new System.Text.RegularExpressions.Regex(p, System.Text.RegularExpressions.RegexOptions.IgnoreCase) If rgx.isMatch(s0) Then Output.Show("匹配") Else Output.Show("不匹配") End If Output.Show(ar) Next 这样严谨不 更改之后的 Dim 收货信息= "北京市北京市房山区长虹区长虹大道759号" Dim 省,值1,值2,值3,值4,市,区,地址 As String Dim p As String = "([省市区县乡镇]|特别行政区|自治区|地区|盟|旗|群岛|街道|街)" Dim p2 As String = "([省市区县乡镇]|街道|街)" Dim r As New System.Text.RegularExpressions.Regex(p) Dim str = r.Split(收货信息) Dim Int As Integer For Each a As String In str int=int+1 Select Case int Case 1 值1=a Case 2 值1=值1 & a Case 3 值2=a Case 4 值2= 值2 & a Case 5 值3=a Case 6 值3=值3 & a Case Else 值4=值4 & a End Select Next Output.Show("省:" & 值1 & ";市:" & 值2 & ";区:" & 值3 & ";地址:" & 值4) Output.Show(int) If int>7 Then Output.Show("正常的省:" & 值1 & ";市:" & 值2 & ";区:" & 值3 & ";地址:" & 值4) Else MessageBox.Show("请加入省市区书写(如:上海市上海市长虹区长虹大道759号)或者手动添加省市区") End If 2020-9-22 09:40:43修改 Dim 省,值1,值2,值3,值4,市,区,地址 As String Dim 收货地址 As String="北京市北京市东城区" Dim Values1() As String Values1 = DataTables("省市区").GetComboListString("市简称").split("|") For Index1 As Integer = 0 To Values1.Length - 1 If 收货地址.Contains(Values1(Index1)) Then Dim Values0() As String Select Case Values1(Index1) Case "济源","仙桃","潜江","天门","神农架","东莞","中山","琼海","儋州","五指山","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中","西南中沙群岛办事处","石河子","阿拉尔","图木舒克","五家渠" 值1="" 值2="" 值3="" 值4="" Dim p As String = "([省市区县乡镇]|特别行政区|自治区|地区|盟|旗|群岛|街道|街)" Dim r As New System.Text.RegularExpressions.Regex(p) Dim str = r.Split(收货地址) Dim Int As Integer For Each a As String In str int=int+1 Select Case int Case 1 值1=a Case 2 值1=值1 & a Case 3 值2=a Case 4 值2= 值2 & a Case 5 值3=a Case 6 值3=值3 & a Case Else 值4=值4 & a End Select Next If int>7 Then Output.Show("正常的省:" & 值1 & ";市:" & 值2 & ";区:" & 值3 & ";地址:" & 值4) Else MessageBox.Show("请加入省市区书写(如:上海市上海市长虹区长虹大道759号)或者手动添加省市区") End If Case Else Values0 = DataTables("省市区").GetComboListString("区","[市简称]= \'" & Values1(Index1) &"\'").split("|") For Index0 As Integer = 0 To Values0.Length - 1 If 收货地址.Contains(Values0(Index0)) Then 省="" 市="" 区="" 地址="" Dim dr As DataRow = DataTables("省市区").Find("市简称=\'"& Values1(Index1) &"\' and 区=\'"& Values0(Index0) &"\'") 省=dr("省") 市=dr("市") 区=dr("区") 地址=收货地址.Replace(省,"").Replace(市,"").Replace(区,"") End If Next End If Next End Select 2020-9-22 10:10:37 改解析收货人以及地址信息 收货地址=解析后 Dim Values1() As String Values1 = DataTables("省市区").GetComboListString("市简称").split("|") For Index1 As Integer = 0 To Values1.Length - 1 If 收货地址.Contains(Values1(Index1)) Then Dim Values0() As String Select Case Values1(Index1) Case "济源","仙桃","潜江","天门","神农架","东莞","中山","琼海","儋州","五指山","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中","西南中沙群岛办事处","石河子","阿拉尔","图木舒克","五家渠" 值1="" 值2="" 值3="" 值4="" Dim p As String = "([市区县乡镇]街道|街)" Dim r As New System.Text.RegularExpressions.Regex(p) Dim str = r.Split(收货地址) Dim Int As Integer For Each a As String In str int=int+1 Select Case int Case 1 值1=a Case 2 值1=值1 & a Case 3 值2=a Case 4 值2= 值2 & a Case Else 值3=值3 & a End Select Next 省="" 市="" 区="" 地址="" Dim dr As DataRow = DataTables("省市区").Find("市简称=\'"& Values1(Index1) & "\'") 省=dr("省") 市=dr("市") 区=值2 地址=值3 Case Else Values0 = DataTables("省市区").GetComboListString("区","[市简称]= \'" & Values1(Index1) &"\'").split("|") For Index0 As Integer = 0 To Values0.Length - 1 \'000 If 收货地址.Contains(Values0(Index0)) Then 省="" 市="" 区="" 地址="" Dim dr As DataRow = DataTables("省市区").Find("市简称=\'"& Values1(Index1) &"\' and 区=\'"& Values0(Index0) &"\'") 省=dr("省") 市=dr("市") 区=dr("区") 地址=收货地址.Replace(省,"").Replace(市,"").Replace(区,"") End If Next End Select End If Next [此贴子已经被作者于2020/9/22 10:10:51编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/9/14 13:35:00 -- 自己测试吧。我是认为没有办法判断的,比如有一个人名叫【赵有钱】,不知道是按赵取姓呢还是取钱姓 |