[Solved] Help with regular expressions



  • I am trying to create a regular expression for a QLineEdit.

    The first character can be any of the following characters, except a '.'.
    The next 0 to 255 characters can be any of the characters listed.

    The following is my code:
    @QRegExp rx ("[A-Za-z0-9!#%&',+;={}~@()\-[]\^\$]{1} [A-Za-z0-9.!#%&',+;={}~@()\-[]\^\$]{0,255}");
    lineEdit->setValidator (new QRegExpValidator (rx, this));@

    If I just have the {0,255} expression in, it works just fine. But, once I add the {1} part in, I can only enter 1 character on my QLineEdit. What am I doing wrong?

    Thanks,
    Kate


  • Moderators

    It looks like it's expecting a space after your first character. (Between the {1} and the [A-Za-z...)



  • Thanks so much! That was the problem.


  • Moderators

    Glad to help!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.