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


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

Submitted by:  Muhali <muhali>
Submitted on:  Fri Apr 19 12:48:49 2013  
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Mon Jul 8 00:59:46 2013, 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

Rik <rik5>
Project Administrator
Tue Apr 23 06:58:40 2013, comment #6:

The regexp help

still needs to be corrected.

Muhali <muhali>
Sun Apr 21 21:28:27 2013, 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>
Project Administrator
Sun Apr 21 10:29:02 2013, 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 Apr 20 19:30:39 2013, comment #3:

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

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>
Project Administrator
Sat Apr 20 08:38:06 2013, comment #2:

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

Muhali <muhali>
Fri Apr 19 21:50:47 2013, 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>
Project Administrator
Fri Apr 19 12:48:49 2013, original submission:

The command

returns [] instead of 1.

Muhali <muhali>


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

Attach File(s):

Attached Files
file #27922:  bug38778-rev2.patch added by mtmiller (1kB - 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
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by muhali (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Jul 8 00:59:46 2013rik5StatusPatch Submitted=>Fixed
      Summaryregexp(\'a\', \'\\<\\w\') != 1=>regexp('a', '\<\w') != 1
    Sun Apr 21 21:28:27 2013mtmillerAttached File-=>Added bug38778-rev2.patch, #27922
      Summaryregexp(\'a\', \'\\<\\w\') != 1=>regexp('a', '\<\w') != 1
    Sat Apr 20 19:30:39 2013mtmillerAttached File-=>Added bug38778.patch, #27914
      StatusConfirmed=>Patch Submitted
      Summaryregexp(\'a\', \'\\<\\w\') != 1=>regexp('a', '\<\w') != 1
    Fri Apr 19 21:50:47 2013mtmillerStatusNone=>Confirmed
      Summaryregexp(\'a\', \'\\<\\w\') != 1=>regexp('a', '\<\w') != 1

    Back to the top

    Powered by Savane 3.1-cleanup1