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]Wrong QRegExp
Qt 6.11 is out! See what's new in the release blog

[Solved]Wrong QRegExp

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.8k 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:
    @ QString str = "asin(";
    str.replace(QRegExp("[^a]{0,1}sin\("),"yes!");
    qDebug() << str;@
    And i get "yes!", why is it happened?
    In advance thank for your help!

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

      Your reg exp is saying match everything where there is everything except for an a one or zero times before the sin.

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

        How can i changed it, on the this site http://gskinner.com/RegExr/ all worked ok, why it is hapanned?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          You should have "ayes!" based on this regexp. Are you sure you have "yes!" only?

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

            Sorry, but i do not fully understand what you said, this is full code whitch i used
            @QString text = lineEdit->text();
            // text, for example = "asin", and after replace it should be = "asin"
            text.replace(QRegExp("[^a]{0,1}sin\("),"Math.sin(");@

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

              [quote author="Ruzik" date="1313230274"]How can i changed it, on the this site http://gskinner.com/RegExr/ all worked ok, why it is hapanned?[/quote]

              "No it didn't":http://regexr.com?2uer8
              Just remove the {0,1} to make it work. However this will also select the character before the sin(. May I suggest something like \bsin( or usage of subexpressions.

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

                Ok, thank you for help!

                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