octave-maintainers
[Top][All Lists]
Advanced

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

Re: Backslashes in regular expression replacement patterns


From: Ben Abbott
Subject: Re: Backslashes in regular expression replacement patterns
Date: Tue, 16 Oct 2012 17:37:57 -0400

On Oct 16, 2012, at 5:00 PM, Rik wrote:

> On 10/16/2012 01:28 PM, Michael D. Godfrey wrote:
>> On 10/16/2012 12:29 PM, Rik wrote:
>>> regexprep ('a', '(\w)', "\\$1")
>>> 
>>> Should it be '\a' or '$1'? 
>>> 
>>> In the first case, one would get the same result from using a replacement
>>> pattern of '\\$1' or "\\$1" which is odd because usually single quotes and
>>> double quotes are not interchangeable.  On the other hand, Perl would
>>> return '\a' for the regexprep above.
>>> 
>> Matlab R2009b returns '\a'
>> 
> Matlab has support for double-quoted strings now?  I thought they didn't 
> support them, and this was only an Octave behavior question.
> 
> --Rik

No.  Only single-quoted strings

regexprep ('a', '(\w)', '\\$1')

ans =

\a

Ben



reply via email to

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