使用正则表达式从mysql列中提取子字符串 [英] extract substring from mysql column using regex

查看:2270
本文介绍了使用正则表达式从mysql列中提取子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的正则表达式为(pnr |(P | p)_.:,!!''-/$ _.:,!!''-/$)+ [_.:,!"'-/$ ] + [0-9] {3} [_.:,!!''-/$] + [0-9] {7}

它正在从列中提取pnr号.

It is extracting pnr number from column .

示例文字: 94eb2c0cb17ef354bb052c57f40c \ r \ nContent-Type:文本/纯文本; charset = UTF-8 \ r \ nContent-Transfer-Encoding pnr:986-097832

sample text : 94eb2c0cb17ef354bb052c57f40c\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding pnr:986-097832

94eb2c0cb17ef354bb052c57f40c \ r \ nContent-Type:pnr:986-097832文本/纯文本; charset = UTF-8 \ r \ nContent-Transfer-Encoding

94eb2c0cb17ef354bb052c57f40c\r\nContent-Type: pnr:986-097832 text/plain; charset=UTF-8\r\nContent-Transfer-Encoding

pnr:986-097832 94eb2c0cb17ef354bb052c57f40c \ r \ nContent-Type:文本/纯文本; charset = UTF-8 \ r \ nContent-Transfer-Encoding

pnr:986-097832 94eb2c0cb17ef354bb052c57f40c\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding

我必须创建一个mysql查询,该查询将仅提取pnr号

推荐答案

SELECT REGEXP_SUBSTR(column, 'pnr:[0-9\-]{10}')
FROM table

这篇关于使用正则表达式从mysql列中提取子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆