[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #45084] regexptranslate incorrectly escapes "<
From: |
Colin Macdonald |
Subject: |
[Octave-bug-tracker] [bug #45084] regexptranslate incorrectly escapes "<" and ">", maybe others |
Date: |
Tue, 12 May 2015 13:35:34 +0000 |
User-agent: |
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0 |
URL:
<http://savannah.gnu.org/bugs/?45084>
Summary: regexptranslate incorrectly escapes "<" and ">",
maybe others
Project: GNU Octave
Submitted by: cbm
Submitted on: Tue 12 May 2015 01:35:32 PM GMT
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
regexptranslate has an "escape" mode which escapes characters.
The docs say: "special meaning for regular expressions are escaped so that
they are treated literally."
But some characters without special meaning are incorrectly escaped:
>> s = '<><>'
s = <><>
>> re = regexptranslate ('escape', s)
re = \<\>\<\>
>> regexp(s, re)
ans = [](1x0)
('re' is just 's' again on Matlab and thus 're' does indeed match 's'. I
believe this is the correct behaviour).
I looked at the implementation and it does look wrong in that it escapes all
non-word characters:
elseif (strcmp ("escape", op))
y = regexprep (s, '([^\w])', '\\$1');
This is https://github.com/catch22/octave-doctest/issues/42.
If someone confirms this, I will try to write a patch which explicitly lists
all characters to be translated.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?45084>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #45084] regexptranslate incorrectly escapes "<" and ">", maybe others,
Colin Macdonald <=