我有像:
这样的字符串26.05.2016/00002Lol
26.05.2016/00003(Lol)
26.05.2016UUUU/00004(Lol)
如何从这些字符串中选择五位数(00002, 00003, 00004
)的序列?
答案 0 :(得分:3)
这五个数字总是在第一个'/'
之后吗?如果是,那么:
SELECT SUBSTRING(col FROM POSITION(col, '/') + 1 FOR 5) AS fivedigits ...
应该这样做。
答案 1 :(得分:1)
(?<=\/)[0-9]{5}
此正则表达式将执行以下操作:
\
字符现场演示
https://regex101.com/r/lD6pW5/1
示例文字
26.05.2016/00002Lol
26.05.2016/00003(Lol)
26.05.2016UUUU/00004(Lol)
样本匹配
[0][0] = 00002
[1][0] = 00003
[2][0] = 00004
NODE EXPLANATION
----------------------------------------------------------------------
(?<= look behind to see if there is:
----------------------------------------------------------------------
\/ '/'
----------------------------------------------------------------------
) end of look-behind
----------------------------------------------------------------------
[0-9]{5} any character of: '0' to '9' (5 times)
----------------------------------------------------------------------