Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Validate e-mail with QRegularExpression

[SOLVED] Validate e-mail with QRegularExpression

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by
    #1

    Hello!

    I am having a problem to validate an e-mail with QRegularExpression.

    I am trying with me@me.com an it returns false

    @
    bool regExpressionRetorno::validaEmail(QString email)
    {
    bool retorno = true;

    qDebug() << email;
    
    QRegularExpression regex("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b");
    
    if(!regex.match(email).hasMatch())
    {
        retorno = false;
    }
    
    return retorno;
    

    }
    @

    Whats is going wrong?

    Thanks in advance.

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0
    • guidupasG Offline
      guidupasG Offline
      guidupas
      wrote on last edited by
      #2

      Solved

      [CODE]
      QRegularExpression regex("^[0-9a-zA-Z]+([0-9a-zA-Z][-._+])[0-9a-zA-Z]+@[0-9a-zA-Z]+([-.][0-9a-zA-Z]+)([0-9a-zA-Z][.])[a-zA-Z]{2,6}$");
      [/CODE]

      Att.
      Guilherme Cortada Dupas

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved