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 wrong works

QRegExp wrong works

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 2.1k 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.
  • B Offline
    B Offline
    bagipro
    wrote on last edited by
    #1

    Hello all, I have a regexp
    @"[^\d]+([^\n]+)"@
    an input string
    @Someword 1234@
    output
    @omeword 1234@
    I wanna skip string before first number and get all rest, but it dont work

    What's wrong? In boost it works

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      [quote author="bagipro" date="1370516249"]
      I wanna skip string before first number and get all rest, but it dont work
      [/quote]

      Does the following do what you want?
      @
      QRegExp rx("[.|\s](\d)");
      rx.setMinimal(true);
      ...
      rx.cap(1); //1234
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • B Offline
        B Offline
        butterface
        wrote on last edited by
        #3

        It is also funny because it changes Some string to ome word without anything from you. ;)

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          then show the code please where you use the QRegExp ;)

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bagipro
            wrote on last edited by
            #5

            butterface, oh yeah :D
            i copy it from 2 resources: from program and from code. I will edit first post

            raven-worx, i write regex-tester
            !http://clip2net.com/clip/m0/1370517856-clip-3kb.png(Picture)!

            So, i find a crutch
            @[^\d]+(\d[^\n]+)@

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bagipro
              wrote on last edited by
              #6

              But why first regexp did not work?

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bagipro
                wrote on last edited by
                #7

                I have a new problem
                @(\w+):(\d+)@
                @text:123@

                output
                @text@

                Why "text" only? I wanna get "text" and "123"

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

                  Hi,

                  if you want to test and validate your regexp, there is the regexp example in Qt's sources that will help you.

                  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
                  0
                  • B Offline
                    B Offline
                    bagipro
                    wrote on last edited by
                    #9

                    Yes, I need to add QRegExp::cap(2). Thanks

                    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