栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

hive自定义函数-手机号合法性自定义函数

hive自定义函数-手机号合法性自定义函数

hive自定义函数-手机号合法性函数
  • 简要
  • 代码
  • 结果:

简要

根据百度百科最新手机号码规则,编写的手机号合法判断自定义函数

链接: 百度百科最新手机号码规则.
此处仅实现了11位手机号码的实现方式

代码
import com.bigdata.hive.Tools.StringTools;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;

public class UdfIsPhone extends UDF {

@Description(
            name = "udf_is_phone",
            value = "_FUNC_(str) - Returns str is phone?0:1",
            extended = "Example:n  > SELECt _FUNC_('15593126538') FROM dual LIMIT 1;n   return    1 "
    )
    static String[] regex = {"^1[3,5,9][0-35-9]\d{8}$","^134[0-8]\d{8}$","^14[5,7,9]\d{8}$","^166\d{8}$","^17[2,3,5,6,7,8]\d{8}$","^18\d{9}$"};
    public int evaluate(final String s) {
            if (StringTools.isNotNull(s)) {
               for( int i=0 ;i 
结果: 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/342731.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号