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


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

Submitted by:  Muhali <muhali>
Submitted on:  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

Add a New Comment(Rich Markup)

You are not logged in

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


( 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

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

The regexp help

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>
Project Administrator
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:

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 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>
Project Administrator
Fri 19 Apr 2013 12:48:49 PM UTC, 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 Files:

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)

    Do you think this task is very important?
    If so, you can 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 08 Jul 2013 12:59:46 AM UTC rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
        Summaryregexp(\'a\', \'\\<\\w\') != 1 => regexp('a', '\<\w') != 1
    Sun 21 Apr 2013 09:28:27 PM UTC mtmiller Attached File- => Added bug38778-rev2.patch, #27922
        Summaryregexp(\'a\', \'\\<\\w\') != 1 => regexp('a', '\<\w') != 1
    Sat 20 Apr 2013 07:30:39 PM UTC mtmiller Attached File- => Added bug38778.patch, #27914
        StatusConfirmed => Patch Submitted
        Summaryregexp(\'a\', \'\\<\\w\') != 1 => regexp('a', '\<\w') != 1
    Fri 19 Apr 2013 09:50:47 PM UTC mtmiller StatusNone => Confirmed
        Summaryregexp(\'a\', \'\\<\\w\') != 1 => regexp('a', '\<\w') != 1

    Back to the top

    Powered by Savane 3.3