0

Hello i'm trying to validate the data (consisting of names of 2 or more words) from a lineedit widget using regular expressions in qt the issue is that qt is allowing anything in the lineedit widget my code is below, thank you.

QRegularExpression Company_Name("/([A-Z|a-z|0-9])/g");
QRegularExpressionMatch Company_Name_Match = Company_Name.match(ui->lineEdit_Company_Name->text())
if(Company_Name_Match.hasMatch())
{
    ErrorLog = ErrorLog + "Company Name contains charagters that are not alphanumeric\n";
    ui->lineEdit_Company_Name->setStyleSheet("border: 1px solid red");

Thank you

Root0x
  • 113
  • 1
  • 2
  • 12

1 Answers1

1

i'm trying to validate the data (consisting of names of 2 or more words)

^[a-zA-Z0-9]+(\s[a-zA-Z0-9]+)+$
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274