bugGNU Octave - Bugs: bug #38778, regexp('a', '\<\w') != 1

 
 

bug #38778: regexp('a', '\<\w') != 1

Submitter:  Muhali <muhali>
Submitted:  Fri 19 Apr 2013 12:48:49 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 08 Jul 2013 12:59:46 AM UTC, comment #7: 

I committed your first patch.  It is the simpler fix and in practice is unlikely to ever be a problem.  Users who are constructing patters, like '\>\w', where there would be a difference don't understand regular expressions.

I also changed the documentation to remove reference to '\b' which is the backspace character.

If there is ever a need, we could use lookahead assertions to exactly match '\<' and '\>'.

Matlab  =>   PCRE


\<   =>   \b(?=\w)
\>   =>   \b(?<=\w)


Rik <rik5>
Group administrator
Tue 23 Apr 2013 06:58:40 AM UTC, comment #6: 

The regexp help


 `\b'
          Match a word boundary


still needs to be corrected.

Muhali <muhali>
Sun 21 Apr 2013 09:28:27 PM UTC, comment #5: 

Here's another attempt at a fix to make PCRE equivalents for \< and \>. It doesn't fully work, needs some attention from a regexp guru.

(file #27922)

Mike Miller <mtmiller>
Group Member
Sun 21 Apr 2013 10:29:02 AM UTC, comment #4: 

Now \< and \> have the same meaning. It is probably less confusing to have \> reserved for end-of-word, to be implemented later.

Muhali <muhali>
Sat 20 Apr 2013 07:30:39 PM UTC, comment #3: 

Right, because \b matches a backspace character for compatibility with Matlab:


octave:1> regexp (char (8), '\b')
ans =  1


The attached change makes \< and \> both work like \b. It's not ideal, but that may be the best we can do with PCRE. Do you know any way we can emulate \< and \> properly with PCRE?

(file #27914)

Mike Miller <mtmiller>
Group Member
Sat 20 Apr 2013 08:38:06 AM UTC, comment #2: 

\< and \> are not part of PCRE. But \b is, and regexp('a', '\b\w') still returns [] and not 1.

Muhali <muhali>
Fri 19 Apr 2013 09:50:47 PM UTC, comment #1: 

Confirmed on both stable and default.

AFAICT the \< and \> sequences are not supported by Perl or PCRE at all. This could be done by translating both into \b before passing down to PCRE, but it's not exactly the same.

Mike Miller <mtmiller>
Group Member
Fri 19 Apr 2013 12:48:49 PM UTC, original submission:  

The command


regexp('a', '\<\w')


returns [] instead of 1.

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #27922:  bug38778-rev2.patch added by mtmiller (1KiB - text/x-patch)
file #27914:  bug38778.patch added by mtmiller (957B - text/x-patch)

 

Depends on the following items: None found

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 muhali (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-07-08 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
        Summaryregexp(\'a\', \'\\&lt;\\w\') != 1 regexp('a', '\<\w') != 1
    2013-04-21 mtmiller Attached File- Added bug38778-rev2.patch, #27922
        Summaryregexp(\'a\', \'\\&lt;\\w\') != 1 regexp('a', '\<\w') != 1
    2013-04-20 mtmiller Attached File- Added bug38778.patch, #27914
        StatusConfirmed Patch Submitted
        Summaryregexp(\'a\', \'\\&lt;\\w\') != 1 regexp('a', '\<\w') != 1
    2013-04-19 mtmiller StatusNone Confirmed
        Summaryregexp(\'a\', \'\\&lt;\\w\') != 1 regexp('a', '\<\w') != 1

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code