1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Rep Power

    How did SELECT 'aXbc' REGEXP '^[a-dXYZ]$'; results in false

    Hi with reference to
    [mysql 5.5 documentation]/regexp.html, sorry I'm a new account so can't post link
    mysql> SELECT 'aXbc' REGEXP '^[a-dXYZ]$'; -> 0
    I still do not understand why the result is false.

    I mean REGEXP '^[a-dXYZ]$'

    means front bank and end the pattern must be in a,b,c,d, X,Y Z set, am I right?

    am I getting things wrong?

  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Rep Power

    the regex you've written down matches a string consisting of a single character of the list a, b, c, d, X, Y, Z..

    If you want a string starting with a character of this list, followed by an arbitrary number of characters and ending with a character of this list, you need:


    Comments on this post

    • mysqlnoob1 agrees : I have try out and yes your answer is correct!
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo