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

# Re: regex substitution

- Date: Wed, 6 Mar 1996 22:39:08 PST
- From:
- Content-Type: text/plain; charset="us-ascii"

    >that's what I was going to answer also, but the question was how could you
    substitute using regexps: you can only use strsub() to substitute fixed strings.
    >
    >Let's take the example that was provided: replacing one or more consecutive
    s's with the letter 't'. As you know, the regexp to match s's is "s+". But
    since match() returns the index numbers of the matched string.. all you'd
    have to do was use those numbers to change the actual string.

    Oh yeah, there is another way to do this:
    if (m=match(string,"%(.*%)s+%(.*%)"))
    string=substitute("%1t%2",m);
    endif

    Since both methods only match the first occurrence of the string, you'd
    probably have to put it in a while loop.

- Prev: Re: regex substitution
- Next: Re: regex substitution
- Index: MOO-cows
- Thread: MOO-cows

Home | Subject Index | Thread Index