octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #35911] Backslash escaping in regexprep replac


From: Burkart Lingner
Subject: [Octave-bug-tracker] [bug #35911] Backslash escaping in regexprep replacement string incompatibility
Date: Tue, 20 Mar 2012 17:00:25 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0

URL:
  <http://savannah.gnu.org/bugs/?35911>

                 Summary: Backslash escaping in regexprep replacement string
incompatibility
                 Project: GNU Octave
            Submitted by: burkart
            Submitted on: Tue 20 Mar 2012 05:00:24 PM GMT
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.6.1
        Operating System: GNU/Linux

    _______________________________________________________

Details:

MATLAB expects backslashes in the replacement string of regexprep(...) to be
escaped as '\\' whereas Octave expects a single backslash. Example:


regexprep('foobar', '[fb]', '\\')


yields "\oo\ar" in MATLAB and "\\oo\\ar" in Octave.


regexprep('foobar', '[fb]', '\')


yields "\oo\ar" in both MATLAB and Octave. However, using single backslashes
is not a real solution. Let's say you want to replace the "f" and "b" in
"foobar" with the character sequence "\n" but not a newline. This would be
achieved with the replacement string "\n" in Octave only whereas that would
cause a newline to be inserted in MATLAB which requires the replacement string
"\\n" for the desired functionality. Another scenario would be that you want
to replace something with two consecutive backslashes. This calls for the
replacement string "\\" in Octave but for "\\\\" in MATLAB.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35911>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]