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. The doc of QRegExp::escape didn't mention backslash
Forum Updated to NodeBB v4.3 + New Features

The doc of QRegExp::escape didn't mention backslash

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 539 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
    sc420
    wrote on last edited by sc420
    #1

    Recently our colleague sent me a code review and it's basically about escaping all special characters except for "?" and "*" since we only allow users to use wildcards but our engine uses regex. I saw the code didn't escape backslash characters and he said he took QRegExp::escape documentation description as a reference:

    Returns the string str with every regexp special character escaped with a backslash. The special characters are $, (,), *, +, ., ?, [, ,], ^, {, | and }.
    

    But after trying to feed \ to QRegExp::escape we found it actually escapes it! We can also see it does escape it in the Qt source code. So I guess the doc should be fixed, but I don't know where I should report this issue so I'm going to raise the concern here.

    JonBJ JKSHJ 2 Replies Last reply
    0
    • S sc420

      Recently our colleague sent me a code review and it's basically about escaping all special characters except for "?" and "*" since we only allow users to use wildcards but our engine uses regex. I saw the code didn't escape backslash characters and he said he took QRegExp::escape documentation description as a reference:

      Returns the string str with every regexp special character escaped with a backslash. The special characters are $, (,), *, +, ., ?, [, ,], ^, {, | and }.
      

      But after trying to feed \ to QRegExp::escape we found it actually escapes it! We can also see it does escape it in the Qt source code. So I guess the doc should be fixed, but I don't know where I should report this issue so I'm going to raise the concern here.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @sc420
      Hello and welcome.

      You raise a reasonable point. However, since you are using QRegExp are you aware that this is no longer a part of Qt6 going forward, it is only in Qt 5 Core Compatibility APIs

      The Qt 5 Core Compat module contains the Qt 5 Core APIs that were removed in Qt 6. The module facilitates the transition to Qt 6.

      Given which they may not be so interested in updating documentation. On your side, are you aware that at some point this may be phased out and you ought think about moving on?

      If you do wish to report this documentation issue you are welcome to do so at https://bugreports.qt.io/

      1 Reply Last reply
      2
      • S sc420

        Recently our colleague sent me a code review and it's basically about escaping all special characters except for "?" and "*" since we only allow users to use wildcards but our engine uses regex. I saw the code didn't escape backslash characters and he said he took QRegExp::escape documentation description as a reference:

        Returns the string str with every regexp special character escaped with a backslash. The special characters are $, (,), *, +, ., ?, [, ,], ^, {, | and }.
        

        But after trying to feed \ to QRegExp::escape we found it actually escapes it! We can also see it does escape it in the Qt source code. So I guess the doc should be fixed, but I don't know where I should report this issue so I'm going to raise the concern here.

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by JKSH
        #3

        [EDIT: @JonB beat me to it! --JKSH]

        Hi, and welcome!

        @sc420 said in The doc of QRegExp::escape didn't mention backslash:

        So I guess the doc should be fixed, but I don't know where I should report this issue so I'm going to raise the concern here.

        Thank you for reporting this. In general, the best place to report issues (including documentation issues) is https://bugreports.qt.io/

        In this particular case though, QRegExp is deprecated so the doc fix will be very low priority. We highly recommend porting to QRegularExpression instead, which has been available since Qt 5.0: https://doc.qt.io/qt-6/qregexp.html#porting-to-qregularexpression

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        2
        • S Offline
          S Offline
          sc420
          wrote on last edited by
          #4

          @JonB @JKSH Thanks for replies. Yes I'm aware that Qt 5 recommends to use QRegularExpression instead. But our project migration to Qt 5 seems to be slow at this point. We'll have to keep using QRegExp for a while. It's good to know where to report doc issues. I'll keep it in mind, 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