Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1910

The RegularExpression 'matches' function no longer returns the start and end position of a match

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 3.0.1
    • 3.1.0
    • Utilities
    • Windows

    Description

      We have recently upgraded from version 2.2.0 to version 3.0.1. Between these versions a change was made to the RegularExpression::matchUnion function, so that it now uses a local version of the context structure. The result of this is that the 'fMatch' member of the context can be changed from its original instance. Therefore, back in the RegularExpression::matches function, just before it returns, it sets the start and end position of the match:

      context.fMatch->setStartPos(0, (int)matchStart);
      context.fMatch->setEndPos(0, matchEnd);

      However, the 'fMatch' object no longer matches the one that was passed through to function (due to what happened in 'matchUnion') and therefore these values don't get returned to the calling function.
      Therefore, I think that in the 'matches' function is should actually be setting the start and end position of the 'pMatch' property that is passed into the function, rather than the 'context.fMatch'.

      The code we are using to call the regular expression is this:

      XERCES_CPP_NAMESPACE::RegularExpression re(expression.c_str());
      if( re.matches( text, &match ) )
      { ...

      where expression = "([\-\(]?\d

      {1,3}

      ([, ]\d

      {3}

      )\.\d[\)]?|[\-\(]?\d+\.\d+[\)]?).*"
      and text = "13.13"

      Attachments

        Activity

          People

            Unassigned Unassigned
            steve roberts Steve Roberts
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: