bugGNU Octave - Bugs: bug #41211, regexp: groups with '?' matching...

 
 

bug #41211: regexp: groups with '?' matching handled different between matlab and octave

Submitter:  Michael C. Grant <mcgrant>
Submitted:  Sun 12 Jan 2014 09:00:15 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Duplicate Assigned to:  None
Originator Name:  Michael C. Grant Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 13 Jan 2014 03:09:29 AM UTC, comment #2: 

I understand. As I said I have worked around it in my own code. I will simply assume that it needs to stay that way.

Michael C. Grant <mcgrant>
Sun 12 Jan 2014 10:14:29 PM UTC, comment #1: 

This is a duplicate of bug #38149.  See the discussion there for more information.  I've done just about all of the work with Octave's regexp code for the last two releases, and unfortunately there are some incompatibilities that are not easy to fix without a full re-write/overhaul of the code.  It is way more than I want to take on as a volunteer, although if we got it crowdfunded or there was a paying client it might be possible.

Rik <rik5>
Group administrator
Sun 12 Jan 2014 09:00:15 PM UTC, original submission:  

If a grouping construct is followed by '?', and that group is not matched, Octave does not return an entry for that token. MATLAB, however, returns an empty string.

At first I thought this is probably not important, and I've already fixed it in my code. Indeed, MATLAB's behavior might be considered wrong, since the empty string will in many cases not be a valid match.

But here's an example where I think the Octave behavior could be potentially problematic. In this case, the final grouping is returned as token #2 in Octave, and token #3 in MATLAB. It seems to me that MATLAB's behavior is better here. After all, is that second token returned by Octave from group 2 or group 3? To determine this, you would have to do additional tests.

Octave:

octave:1> str = 'test::'
str = test::
octave:2> toks = regexp(str, '^([a-zA-Z]w*)((.*))?(.+)?$', 'tokens' )
toks =
{
  [1,1] =
  {
    [1,1] = test
    [1,2] = ::
  }
}


Matlab:

>> str = 'test::'
str =
test::
>> toks = regexp(str, '^([a-zA-Z]w*)((.*))?(.+)?$', 'tokens' )
toks =
    {1x3 cell}
>> toks{:}
ans =
    'test'    ''    '::'




Michael C. Grant <mcgrant>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mcgrant (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-22 mtmiller Open/ClosedOpen Closed
    2014-01-13 rik5 StatusNone Duplicate
    2014-01-12 rik5 Dependencies- Depends on bugs #38149

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code