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. QRegExp

QRegExp

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 478 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    SP0567
    wrote on last edited by
    #1

    Hi Team,

    I need to write the QRegExp such that it should work for the below.

    Accepted input
    TS R01L(single word)
    TS RWY01L(single word)
    TS R01L TS R02L TS R01R (Repeated word TS RO1L)
    TS RWY1L TS RWY02L TS RWY01R(Repeated word TS RWY1L)

    Failure Input (I don't know the regExp for the below check)
    TS R01L TS RWY02L( COmbination of .. R.... RX....... should through the error)
    TS RWy01L TS R02L( COmbination of .. RX.... .. R....... should through the error)

    i write with two separate QRegExp.But I could not write combination of the two.
    QRegExp m_rxWindShearRwy,m_rTearShearRwy;
    m_rxTearShear.setPattern("(TS\sR\d{2}(L|C|R|)?)\b");
    m_rTearShearRwy.setPattern("(TS\sR\d{2}(L|C|R|)?)\b");

    Please help me to resolve this.

    I creates a simple qt project with QLineEdit,QLabel,QPushButton and assume that InputValue is typed in the QLineEdit and user clicked on the clickMe button, it should validate the above condition.

    Please help me.since i could not i upload the,i didn't upload it

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Unless you are using Qt 4, please move to QRegularExpression as QRegExp should be considered deprecated.

      As for developing your regex, build and run the https://doc.qt.io/qt-5/qtwidgets-tools-regularexpression-example.html).

      As for your problem should the "base unit" be "TS something" ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Unless you are using Qt 4, please move to QRegularExpression as QRegExp should be considered deprecated.

        As for developing your regex, build and run the https://doc.qt.io/qt-5/qtwidgets-tools-regularexpression-example.html).

        As for your problem should the "base unit" be "TS something" ?

        S Offline
        S Offline
        SP0567
        wrote on last edited by
        #3

        @sgaist Thanks for your reply. I am using Qt 4.8 version.
        I hope you understand my problem

        JonBJ 1 Reply Last reply
        0
        • S SP0567

          @sgaist Thanks for your reply. I am using Qt 4.8 version.
          I hope you understand my problem

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @sp0567
          If you have two separate regular expression patterns, P1 and P2, and you want either of them to be acceptable, you can always combine them into a single expression by using the | ("OR") like: (P1)|(P2).

          Having said that, it looks to me as though your two are identical already? I can't see any differences.... And if they are TS\sR\d{2}(L|C|R|)?)\b it looks to me that is illegal, (L|C|R|) has an unacceptable trailing | ?

          When developing complex regular expressions, a site like https://regex101.com/ can help you play more easily than in code. It won't have exact support for QRegExp, but should be close enough that you can deal with any particular differences.

          1 Reply Last reply
          2
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You then have the corresponding tool for QRegExp.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            • Login

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