[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: enhance index builtin
From: |
Gary V. Vaughan |
Subject: |
Re: enhance index builtin |
Date: |
Thu, 19 Feb 2009 14:21:03 +0700 |
Hi Eric,
2009/2/10 Eric Blake <address@hidden>:
> -----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: address@hidden (\(\
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 ("("_)