Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-131242

Non-word-boundaries in a regex are sometimes doubled

    XMLWordPrintable

Details

    Description

      Consider for example the following code expression:

      "12345,897".replace(/\B(?=(\d{3})+(?!\d))/g, ".")
      

      In QML this seems to produce `12..345,897` (with a double dot).

      Other engine seems to produce a single dot replacement, and indeed it might generally be expected that this should be the outcome of such a replacement.

      A small modification to the above expression:

      "12345,897".replace(/\B/g, ".")
      

      Produces `1..2.3.4.5,8..9.7` such that non-word-boundaries in certain positions seems to be doubled, albeit not always.

      A further modification:

      console.log("1_22-33;44:55,88+99*77".replace(/\B/g, "."))
      

      Produces `1.._.2.2-3..3;4..4:5..5,8..8+9..9*7..7` which seems to imply, as the original pattern did, that replacements on non-word-boundaries are being duplicated for the first non-word-boundary after a word-boundary.

      In general, we would expect non-word-boundaries to not produce duplicated replacements. The implementation should be investigated to ensure that replacements on non-word-boundaries are not duplicated anymore.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              diseraluca Luca Di Sera
              diseraluca Luca Di Sera
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes