bugGNU Octave - Bugs: bug #44641, strsplit fails to split with a...

 
 

bug #44641: strsplit fails to split with a delimiter of '<' or '>'

Submitter:  None
Submitted:  Fri 27 Mar 2015 03:28:26 AM UTC
   
 
Category:  Octave Function Severity:  5 - Blocker
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Richard Lobb Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.1
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 29 Mar 2015 04:56:01 AM UTC, comment #4: 

Thanks for the super-quick fix, guys.

Richard

Anonymous
Sun 29 Mar 2015 02:39:30 AM UTC, comment #3: 

I overhauled the function in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/7569e880d56c).  Along the way I also fixed this bug.  It will be a part of the 4.0 release.

Rik <rik5>
Group administrator
Fri 27 Mar 2015 05:16:35 PM UTC, comment #2: 

The intent of the code is to escape anything that might look like a special character to a regular expression.  The code currently takes anything which is not a work character and escapes it which works great for '?' which is escaped to '\?'.  Unfortunately, '\>' and '\<' are actual regular expressions themselves which mean end-of-word and beginning-of-word.  Need to take a look at the PCRE reference manual and determine if there are any other such special expressions preceded by a slash and add them to line 191 in strsplit.m.

Rik <rik5>
Group administrator
Fri 27 Mar 2015 08:34:42 AM UTC, comment #1: 


The problem is with line 191 in strsplit.m


     del = regexprep (del, '([^\w])', '\\$1');


which changes '>' to '\>'

Avinoam Kalma <avinoam>
Group Member
Fri 27 Mar 2015 03:28:26 AM UTC, original submission:  

strsplit cannot split a string using a separator of '<' or '>'.

Here's the console output from a simple failing test:


octave:1> strsplit('xxx<yyy', '<')
ans =
{
  [1,1] = xxx<yyy
}
octave:2>


Compare that with the output with Octave, V3.6.4, which produces the correct output:


octave:1> strsplit('xxx<yyy', '<')
ans =
{
  [1,1] = xxx
  [1,2] = yyy
}
octave:2>


or using Matlab R2013b and R2014b:


>> strsplit('xxx<yyy', '<')

ans =

    'xxx'    'yyy'

>>


'>' also fails but all other separators (at least those with ordinal values between 32 and 126 inclusive) are fine. The output from the following script:


for i = 32 : 126
    sep = char(i);
    line = ['xxx' sep 'yyy'];
    if sep == 'x' || sep == 'y'
        continue
    end
    bits = strsplit(line, sep);
    if length(bits) ~= 2
       fprintf('Failed with sep of %c (%d)\n', sep, i);
    end
end


is


Failed with sep of < (60)
Failed with sep of > (62)



Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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 jwe (Updated the item)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by None (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-03-29 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2015-03-27 jwe Severity3 - Normal 5 - Blocker
        Item GroupIncorrect Result Regression

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code