Aw: Re: regexp: matching expressions b4 and after ....

David Bateman David.Bateman at motorola.com
Tue Sep 9 09:04:11 CDT 2008


Ben Abbott wrote:
> On Tuesday, September 09, 2008, at 06:17AM, <giovanni.lombardo at arcor.de> wrote:
>   
>> Hi,
>>
>> thanks for the reply Ben. 
>> As you see in your attempt, also the first "(-1)" gets replaced, which is exactly what the regexprep example command (in MATLAB) avoids.
>>     
>
> hmmm ... Matlab gives me the result below ...
>
>   
>>> g='x^(-1)+y(-1)+z(-1)=0';
>>> regexprep(g,'(?<=[a-z]*)\(\-[1-9]*\)','\_minus1')
>>>       
> ans =
> x^_minus1+y_minus1+z_minus1=0
>
> What does matlab give you?
>
>   
Yes the pattern should be '(?<=[a-z]+)\(\-[1-9]*\)' to get the desired 
behavior.

D.

-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



More information about the Help-octave mailing list