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正則表達式的規(guī)則拆分,返回index指定的字符。

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

注意:index=2,對應的是pattern中第二個括號的內(nèi)容。若為0,則是括號內(nèi)全部內(nèi)容


regexp_replace

語法: regexp_replace(string A, string B, string C)?

返回值: string?

說明:將字符串A中的符合java正則表達式B的部分替換為C。

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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容