mysql REGEXP 匹配以 2 位数字结尾且前面仅包含非数字的字符串

Ife*_*kwo 2 regex mysql sql select

我为此付出了很大的努力。

在 MySQL 中,我想查询列中以两位数结尾的字符串。我不在乎前面还有什么,只要最后一个字符是两位数字,前面至少有一个非数字

例如,这些字符串应该匹配:

"Nov. 12th, 60"

"34 Bar 56"

"Foo-BAR-01"

"33-44-55"

"-------88"

"99"
Run Code Online (Sandbox Code Playgroud)

当我这样做时:

SELECT <string> REGEXP <pattern>
Run Code Online (Sandbox Code Playgroud)

现在,这<pattern>就是我需要帮助的地方。

谢谢。

Ped*_*ito 5

SELECT * FROM mytable WHERE mycolumn REGEXP "^.*[^0-9][0-9]{2}$";\n
Run Code Online (Sandbox Code Playgroud)\n\n

正则表达式解释:

\n\n
^.*[^0-9][0-9]{2}$\n\nAssert position at the beginning of the string \xc2\xab^\xc2\xbb\nMatch any single character that is NOT a line break character \xc2\xab.*\xc2\xbb\n   Between zero and unlimited times, as few or as many times as needed to find the longest match in combination with the other quantifiers or alternatives \xc2\xab*\xc2\xbb\nMatch any single character that is NOT present in the list below and that is NOT a line break character \xc2\xab[^0-9]\xc2\xbb\n   A character in the range between \xe2\x80\x9c0\xe2\x80\x9d and \xe2\x80\x9c9\xe2\x80\x9d \xc2\xab0-9\xc2\xbb\nMatch a single character in the range between \xe2\x80\x9c0\xe2\x80\x9d and \xe2\x80\x9c9\xe2\x80\x9d \xc2\xab[0-9]{2}\xc2\xbb\n   Exactly 2 times \xc2\xab{2}\xc2\xbb\nAssert position at the very end of the string \xc2\xab$\xc2\xbb\n
Run Code Online (Sandbox Code Playgroud)\n