changeset 21453:04e0598f8b94 stable

Allow strsplit to use '+' as a delimiter (bug #47403). * strsplit.m: Add '+' to regexprep call to escape characters that have special meaning in regexp.
author Lachlan Andrew <lachlanbis@gmail.com>
date Tue, 15 Mar 2016 19:02:08 +1100
parents 882cb9f032ce
children ebd93e63b48e 5162cdfb56d8
files scripts/strings/strsplit.m
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/strings/strsplit.m	Thu Mar 10 15:38:31 2016 -0500
+++ b/scripts/strings/strsplit.m	Tue Mar 15 19:02:08 2016 +1100
@@ -196,7 +196,7 @@
       del = do_string_escapes (del);
     endif
     ## Escape characters which have a special meaning in regexp.
-    del = regexprep (del, '([{}()[\]^$.*?|\\])', '\\$1');
+    del = regexprep (del, '([{}()[\]^$.*?+|\\])', '\\$1');
   endif
 
   if (isempty (str))
@@ -301,6 +301,9 @@
 %!assert (strsplit ("xxx<yyy", "<"), {"xxx", "yyy"})
 %!assert (strsplit ('xxx\yyy', '\'), {"xxx", "yyy"})
 
+## Bug #47403
+%!assert (strsplit ('xxx+yyy', '+'), {"xxx", "yyy"})
+
 ## Test input validation
 %!error strsplit ()
 %!error strsplit ("abc", "b", true, 4)