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

Regression: RegExp in QML returns ‘undefined’

XMLWordPrintable

    • 19025ab3422658ab27415cee99336d88a4ae19fa (qtdeclarative)

      RegExp.$1 is not returning the collect value with Qt 5.2. When the RegExp is used with QML and JavaScript it returns ‘undefined’. This was working correctly with Qt 4.8.

      The code below can be used to reproduce the issue. It should have "Text1.TextNew" as the text, instead it's "undefined.TextNew".

      import QtQuick 2.0
      
      Item
      {
          width: 360
          height: 360
      
          Component.onCompleted:
          {
             console.debug(text.text);
          }
      
          Text
          {
             id: text
             text: regExpTest("Text1.TextOld", ".TextNew");
             anchors.centerIn: parent
          }
      
          function regExpTest(orgText, replaceText)
          {
             var result = "";
             var test =/(Text1)\..*$/;
      
             var matchResult = orgText.match(test)
             if (matchResult !== null)
             {
                result = RegExp.$1 + replaceText;
             }
      
             return result;
          }
      }
      

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

            shausman Simon Hausmann
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes