[最佳答案] MySQL version: ^[^.]+[0-9]+[ab](-[^.]+)?[[:>:]] JavaScript version: ^[^.]+[0-9]+[ab](-[^.]+)?\b regex101.com doesn't support MySQL flavor regexp, so I only give the JavaScript version. test1bw.test.example.net is added as a test string. [[:>]] is specific to MySQL. For JavaScript, \b should be used instead of [[:>]]. [[:>]] is a Zero-Length Assertion matching at the end of a word (position preceded by but not followed by an ASCII letter, digit, or underscore). \b matches at a positi