hive的正则表达式

regexp

语法: A regexp B 

操作类型: strings 

描述: 功能与rlike相同

注:rlike是正则,like是通配符

select * from pg_hist_user_goldcoin_inout where dtime regexp '2018-04-13 00:00:04' limit 12;



regexp_extract

语法: regexp_extract(string subject, string pattern, int index) 

返回值: string 

说明:将字符串subject按照pattern正则表达式的规则拆分,返回index指定的字符。

select regexp_extract(product,'(\\w+).*?(\\w+)', 2) from pg_hist_user_goldcoin_inout where dt='20180501' and ntype=6;

注意:index=2,对应的是pattern中第二个括号的内容。若为0,则是括号内全部内容


regexp_replace

语法: regexp_replace(string A, string B, string C) 

返回值: string 

说明:将字符串A中的符合java正则表达式B的部分替换为C。

select regexp_replace("junjie.abc","junjie","abc");   -- 输出:   abc.abc

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容