在mysql中查找正则表达式子字符串的位置 [英] Find the position of a regex substring in mysql

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

问题描述

我需要从多行文本中提取一些数据字段.我要查找的数据始终采用相同的格式(来自#.#####.##########"),但它始终包含不同的数据.我知道我可以使用正则表达式来确定是否满足该模式...但我知道该模式已满足.我想知道在字符串中的哪个位置满足该模式,以便我可以从那里将其子串起来.这可能吗?

I need to extract a few fields of data from many lines of text. The data I am looking for is always in the same format ("from #.#####.##########") but it always contains different data. I know I can use regex to determine if that pattern is met... but I know the pattern is met. I want to know where in the string the pattern is met so that I can substring it out of there. Is that possible?

所以一些文本行可能看起来像...
哦,你好.等等等等等等.来自 1.12345.1234567890 doopeeedoo 哇!
好先生!来自 3.98766.123487650 和其他一些东西!

So a few of the lines of text might look like...
Oh, hello there. Blah blah blah. from 1.12345.1234567890 doopeedoo whoop!
Lay tee dah good sir! from 3.98766.123487650 and some other stuff!

提前致谢!

推荐答案

正如 Orbling 所指出的,似乎没有返回字符串的函数,只告诉它是否存在.我最终使用了野生子字符串和索引搜索功能.

As Orbling noted, there doesn't seem to be a function for returning the string, only telling if it exists or not. I ended up using wild substring and index search functions.

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

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