最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
教你用正则表达式提取数字和小数点
时间:2026-09-29 11:50:01 编辑:袖梨 来源:一聚教程网
1、初识
1.1、纯数字提取
-- "提取123abc提取":提取当前字符当中的123 -- 1.Hive:select regexp_replace('提取123abc提取','[^0-9]+','') "123"select regexp_replace('提取123abc提取','D','') "提取123abc提取" -- 2.PG: 'g':global,全局替换select regexp_replace('提取123abc提取','[^0-9]+','','g' ) "123"select regexp_replace('提取123abc提取','D','','g' ) "123"
1.2、带有小数点数字提取
-- "提取123.11abc提取":提取当前字符当中的123.11 -- 1.Hive:小数或者整数数据提取select regexp_extract('提取123.11abc提取','[0-9]+([.]{1}[0-9]+){0,1}',0) "123.11"select regexp_extract('提取123abc提取','[0-9]+([.]{1}[0-9]+){0,1}',0) "123" -- 2.PG:select regexp_replace('提取123.11abc提取','[^d.d]','','g') "123.11"
2、语法
3、实例代码
-- PG:regexp_match:匹配函数select regexp_match('会议事业部69.57%/','[d.d]{1,}')"{69.57}"select regexp_match('会议事业部69%57%/','[d%d]{1,}')"{69%57%}"-- 子表达式中:[d.d]:这时候:'.' 不再是匹配除"rn"之外的任何单个字符select regexp_match('会议事业部69%57%/','[d.d]{1,}')"{69}"
4、参考Demo
-- PostgreSQL正则表达使用https://blog.cs**d*n.net/qq_22994783/article/details/82699559-- Hive常用正则表达式https://cloud.*te*nc*ent.com/developer/article/1538552
总结
到此这篇关于用正则表达式提取数字和小数点的文章就介绍到这了,更多相关表达式提取数字小数点内容请搜索一聚教程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持一聚教程网!
相关文章
- nk-design:实践指南 10-02
- intent-verify:AI Agent 工具实践指南 10-02
- ubuntu-bootstrap:实践指南 10-02
- euparliamentmonitor:AI Agent 工具实践指南 10-02
- clueless:AI Agent 工具实践指南 10-02
- riksdagsmonitor:AI Agent 工具实践指南 10-02