Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]QRegExp
Qt 6.12 LTS is out! See what's new in the release blog

[solved]QRegExp

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 4.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hellow, i have this code:
    @if (rgb.contains(QRegExp("[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3}")))@
    program should recognize the RGB arguments, but it does not work, whereas if you check here http://gskinner.com/RegExr/, then everything works fine, instead of trying to write \, - does not work

    1 Reply Last reply
    0
    • S Offline
      S Offline
      soroush
      wrote on last edited by
      #2

      You need to set Greedy flag on and use QRegexp2 syntax.
      To clarify:
      @
      QRegexp re("[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3}");
      re.setMinimal (false);@

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Wouldn't this regexp match "FFF,FFF,FFF" - which is definitly not a valid RGB value - too?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          soroush
          wrote on last edited by
          #4

          You are doing something wrong. I tested and it matches:

          !http://s1.picofile.com/file/6870501006/screenshot16.png(test)!

          @[0-9a-fA-F]{1,2}@ also won't work for validating rgb hex values. Could you give your regexp declaration code?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            If i write
            @ QRegExp re("[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3}");
            re.setMinimal(true);
            if (rgb.contains(re))@
            It is doesnt work too

            1 Reply Last reply
            0
            • S Offline
              S Offline
              soroush
              wrote on last edited by
              #6

              While I think
              @"[0-9a-fA-F]{2},[0-9a-fA-F]{2},[0-9a-fA-F]{2}"@
              will be a better choice, your expression works for me with Regexp and Regexp2 syntaxes.

              Setting greedy mode to on means set minimal to of...;) you should:
              @
              re.setMinimal(false);
              @

              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
              • Unsolved