String will be consider valid if it starts with letters MS and must contain numeric values 0-9, maximum numeric values allowed are 7.
Valid strings :
MS1234567
MS3434344
MS4534523
Invalid sting:
MS1234567-V2
MS3434344:old
YU4534523
MS4534523768
TY4534523DEL
This the query I tried, I am getting blank result. Where I am going wrong
SELECT MY_STRING_COLUMN
FROM MY_TABLE_NAME
WHERE `MY_STRING_COLUMN` REGEXP '^[MS]{2}\d{7}';
Reference I got from this Stackoverflow post
{2}, add anchor -^MS\d{7}$(MySQL 8+) /^MS[0-9]{7}$(MySQL before 8).[MS]only matches a single char,MorS, thus[MS]{2}matchesMM,SS,SM, orMS. Without$, you may match the pattern just at the start of the string, but there may be much more than that later.\dworks with MySQL'sREGEXP.