Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这有效:
mysql> SELECT '123456789' REGEXP '.{3}';#1 mysql> SELECT '123456789' REGEXP '.{10}';#2
但不是这个:
mysql> SELECT * FROM mymodel WHERE some_text_field REGEXP '.{100}';#3
抛出异常:错误 1139(42000):从正则表达式中得到错误“无效的重复计数”
这意味着您在此字段中没有 100 个或更多字符的字符串。 如果您只想检查这种情况,您可以尝试这样做:
SELECT * FROM mymodel WHERE LENGTH(some_text_field) = 100 ;