我有几个用于匹配 ISBN 10 的 PHP 正则表达式,但找不到与 MySQL 的 REGEXP
兼容的一个,有人可以帮我在 MySQL 中匹配 ISBN 10 吗?
我试过这个(在 PHP 中有效但在 MySQL 中无效)
"^(97(8|9))?\d{9}(\d|X)$"
以下是我运行此正则表达式所针对的一些值:
ISBN10: 0470945176
by Paul D. Kimmel
Publisher: John Wiley & Sons
Copyright year: © 2011
和
Thomas E. Creighton (Author)
ISBN-10: 0471153028
Publisher: Wiley-Interscience; 1 edition (April 8, 1999)
2878 pages
最佳答案
\d
快捷方式在 MySQL 正则表达式中不存在。使用 [[:digit:]]
字符类代替:
"^(97(8|9))?[[:digit:]]{9}([[:digit:]]|X)$"
查看 sqlfiddle .
关于php - 正则表达式 mysql 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14419628/