regexms-accesssql-like

Microsoft office Access `LIKE` VS `RegEx`


I have been having trouble with the Access key term LIKE and it's use. I want to use the following RegEx (Regular Expression) in query form as a sort of "verfication rule" where the LIKE operator filters my results:

"^[0]{1}[0-9]{8,9}$"

How can this be accomplished?


Solution

  • I don't think Access allows regex matches (except in VBA, but that's not what you're asking). The LIKE operator doesn't even support alternation.

    Therefore you need to split it up into two expressions.

    ... WHERE (Blah LIKE "0#########") OR (Blah LIKE "0########")
    

    (# means "a single digit" in Access).