Re: enhance index builtin
"Gary V. Vaughan" <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi Eric, 2009/2/10 Eric Blake <[email protected]>: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > After my recent enhancement to substr, I noticed that index could also be > made more useful if it took an optional starting index. For example: > > index(`a(`b', `b')', `b', `4') > > is much different than > > index(eval(4 + substr(`a(`b', `b')', 4))) > > because of the interference caused by splitting nested quotes in substr. > > > Technically, regexp could also be made more useful with a starting index, > but I don't see how to add that in without breaking backwards > compatibility (since regexp already has an optional argument that changes > whether the result is the index where the match was found, vs. a > substitution pattern using the matched pattern). With the enhancements to argument parsing we discussed some time ago: regexp(`a(`b', `bb+')', `b+', ${offset=4}) => 5 regexp(`a(`b', `bb+')', `b+', `c', ${offset=4}) => a(b, c+) regexp(`a(`b', `bb+')', `b+', ${resyntax=BASIC}, ${offset=4}) => 6 regexp(`a(`b', `bb+')', `b+', `c', ${resyntax=BASIC}, ${offset=4}) => a(b, bc) :) Cheers Gary -- Email me: [email protected] (\(\ Read my blog: http://blog.azazil.net ( o.O) And my other blog: http://www.machaxor.net (uu )o ...and my book: http://sources.redhat.com/autobook ("("_)