Ashley Sanders writes:
>>>> Find all filenames that end in '.html', which can't otherwise be
>>>> accomplished unless you can start a number of characters back from
>>>> the end.
>>> If that's why you want, then why not create an operator or modifier
>>> such as "ends-with", rather than creating an obscure and error prone
>>> substring modifier?
>>
>> That's pretty much what Rob has done, except that instead of a limited
>> "ends-with" modifier, he's made a more general "count backwards from
>> the end" modifier.
>
> The other difference is that an "ends-with" modifier doesn't need
> to be coded with the length of the string you are looking for, eg:
>
> foo.fileName =/ends-with .html
>
> as opposed to
>
> foo.fileName =/substring=-5 .html
>
> So, whatever is constructing this query doesn't need to measure
> the length of the thing they are looking for. And if it is a human
> constructing this query, then it is one less error prone operation
> to perform.
True.
>> And it is spelled "-". Any cosmetic resemblance
>> to negative numbers should be ignored: the use of the "-" character is
>> arbitrary. In fact, we could use (say) "$" instead, like this:
>>
>> foo.fileName =/substring=$5 .html
>>
>> So that all of the string except the first and last characters would
>> be written:
>>
>> foo.fileName =/substring=2,$1 ark_side_of_the_moo
>
> I know you are only suggesting $ as an example, but let me say now
> that $ would be a really bad choice as it comes with a lot of
> historical baggage, especially when it appears as in your example
> above. (Just think perl and shell scripts.)
If you think _that's_ a bad choice, you should see what I first
thought of! :-)
(Answer: "+")
_/|_ ___________________________________________________________________
/o ) \/ Mike Taylor <[log in to unmask]> http://www.miketaylor.org.uk
)_v__/\ "Taking reservations for eternity: Smoking or Non-smoking" --
Church Sign Board.
|