[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Aw: Re: regexp: matching expressions b4 and after ....
From: |
giovanni . lombardo |
Subject: |
Aw: Re: regexp: matching expressions b4 and after .... |
Date: |
Tue, 9 Sep 2008 12:17:46 +0200 (CEST) |
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.
In practice I'm looking for the look-around operators for OCTAVE as described
in MATLAB.
----- Original Nachricht ----
Von: Ben Abbott <address@hidden>
An: address@hidden
Datum: 08.09.2008 18:22
Betreff: Re: regexp: matching expressions b4 and after ....
> On Monday, September 08, 2008, at 11:38AM, <address@hidden>
> wrote:
> >Hi,
> >
> >I'm trying to convert a set of matlab codes into Octave. These codes
> heavily use string manipulation functions
> >
> >In particular I'm trying to extract a set of equations from an ASCII file.
> From these equations I extract/replace variables etc.
> >
> >So, for example, I have g="x^(-1)+y(-1)+z(-1)=0"
> >
> >I need to extract/replace x, y and (-1). So, for example, I used the
> command regexprep(g,'(?<=[a-z]*)\(\-[1-9]*\)','\_minus1')
> >
> >which returned "x^(-1)+y_minus1+z_minus1"
> >
> >Can I do the same in Octave? How?
> >
>
> Doesn't work for me either
>
> octave:1> g="x^(-1)+y(-1)+z(-1)=0"
> g = x^(-1)+y(-1)+z(-1)=0
> octave:2>
> octave:2> regexprep(g,'(?<=[a-z]*)\(\-[1-9]*\)','\_minus1')
> error: syntax error in pattern
>
> Running Matlab2007b
>
> >> g='x^(-1)+y(-1)+z(-1)=0';
> >> regexprep(g,'(?<=[a-z]*)\(\-[1-9]*\)','\_minus1')
> ans =
> x^_minus1+y_minus1+z_minus1=0
>
> I'd suggest you try to isolate the error. Perhaps if the developers knew
> where the specific problem was they could fix it.
>
> I'm not experienced with regexp, but the simpler one below works for your
> example.
>
> regexprep(g,'\(\-[1-9]*\)','_minus1')
> ans = x^_minus1+y_minus1+z_minus1=0
>
> Ben
>
- Aw: Re: regexp: matching expressions b4 and after ....,
giovanni . lombardo <=
- Re: Aw: Re: regexp: matching expressions b4 and after ...., David Bateman, 2008/09/09
- [Changeset] Re: Aw: Re: regexp: matching expressions b4 and after ...., David Bateman, 2008/09/09
- Re: Aw: Re: regexp: matching expressions b4 and after ...., David Bateman, 2008/09/09
- Re: Aw: Re: regexp: matching expressions b4 and after ...., Ben Abbott, 2008/09/09
- [Changeset] Re: Aw: Re: regexp: matching expressions b4 and after ...., David Bateman, 2008/09/09
- [Changeset] Re: Aw: Re: regexp: matching expressions b4 and after ...., John W. Eaton, 2008/09/09
- Re: [Changeset] Re: Aw: Re: regexp: matching expressions b4 and after ...., Jaroslav Hajek, 2008/09/10
- Re: [Changeset] Re: Aw: Re: regexp: matching expressions b4 and after ...., David Bateman, 2008/09/10
Re: Aw: Re: regexp: matching expressions b4 and after ...., Ben Abbott, 2008/09/09