开发者

MySQL regexp for matching list of numbers in a string

I have several rows with strings similar to this: 1,19|11|14,2开发者_JAVA技巧

The info I want to look at is: 19|11|14 (which is a list of the numbers, 19 11 and 14)

This info should be matched to see if any of the numbers are in the range between 8 and 13

What's the most effective way to accomplish this? I tried using a regexp like:

[^0-9]*(8|9|10|11|12|13)[^0-9]*

But this would also match the number 9 which is actually 19.

Other methods for parsing the string is also welcomed, only functions available in MySQL 5.0 can be used.


From what I remember MySQLs Regex support is very simplistic I'm not sure how possible this will actually be. I don't believe it supports word boundaries or look around assertions. How about this...

(^|[^0-9])(8|9|10|11|12|13)([^0-9]|$)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜