bugGNU Octave - Bugs: bug #48883, regexp(rep): Matlab compatibility...

 
 

bug #48883: regexp(rep): Matlab compatibility with empty match groups.

Submitter:  Kai Torben Ohlhus <siko1056>
Submitted:  Wed 24 Aug 2016 12:49:46 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Duplicate Assigned to:  siko1056
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 24 Aug 2016 03:56:34 PM UTC, comment #2: 

See bug #38149.  It may be related.

I believe the problem is very specific to an empty match in the first position.

As a canonical example,


regexp ('bc', '(^)(b)(c)', 'tokens')
ans =
{
  [1,1] =
  {
    [1,1] = b
    [1,2] = c
  }
}


But, an empty match elsewhere is okay, and returns a null token.


regexp ('bc', '(b)(a?)(c)', 'tokens', 'emptymatch')
ans =
{
  [1,1] =
  {
    [1,1] = b
    [1,2] =
    [1,3] = c
  }
}


It may also be specifically related to the '^' pattern.  The example below is almost the same as the one above, but doesn't work.


regexp ('bc', '(^a?)(b)(c)', 'tokens', 'emptymatch')
ans =
{
  [1,1] =
  {
    [1,1] = b
    [1,2] = c
  }
}



Rik <rik5>
Group administrator
Wed 24 Aug 2016 03:36:54 PM UTC, comment #1: 

Please take a look at bug #38149 (and close this as a duplicate if you think appropriate). I think there has been some partial work done on that bug report but was left undone, later comments say this is more difficult than it first appears.

Mike Miller <mtmiller>
Group Member
Wed 24 Aug 2016 12:49:46 PM UTC, original submission:  

I hope it is an easy one:

Matlab R2016a:

>> regexprep ('abc', '(^|a)(b)(c)', 'IN$2$3')
ans = INbc

>> regexprep ('bc', '(^|a)(b)(c)', 'IN$2$3')
ans = INbc

>> [~,~,~,a,b]=regexp ('bc', '(^|a)(b)(c)')
a = 'bc'
b = {1x3 cell}
>> b{:}

ans = ''    'b'    'c'


Octave:

>> regexprep ('abc', '(^|a)(b)(c)', 'IN$2$3')
ans = INbc

>> regexprep ('bc', '(^|a)(b)(c)', 'IN$2$3')
ans = INc

>> [~,~,~,a,b]=regexp ('bc', '(^|a)(b)(c)')
a =
{
  [1,1] = bc
}
b =
{
  [1,1] =
  {
    [1,1] = b
    [1,2] = c
  }
}


Kai Torben Ohlhus <siko1056>
Group Member

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by siko1056 (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
    2016-08-24 siko1056 StatusIn Progress Duplicate
        Open/ClosedOpen Closed
    2016-08-24 mtmiller Dependencies- Depends on bugs #38149

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code