On Wed, Aug 22, 2018 at 10:42 AM Tyler, Matt <matt.tyler@xxxxxxxxxxxxxx> wrote:

For me I don't understand the need to have repeating placeholders in a string that you do not want to replace with a value. "When we use long varying strings with placeholders some of them are repeated and we cannot use %SCANRPL." What's the purpose of having same named placeholders that you don't want to replace with the same value? If they need to be different then use a different placeholder name.

If you have a lot of placeholders to replace, and you know you will be
filling them sequentially, then it's a needless annoyance to have to
come up with different names for them all.

In Python, there had been a string interpolation feature that worked like this:

template = "Substitute {0}, {1}, and {2} for great justice."
final_string = template.format('all', 'your', 'base')

The numbered placeholders were handy if you wanted to reorder or
repeat some substitution values. But the most typical case by far was
just one-to-one sequential replacement. So at some point, they
loosened the syntax to also allow

template = "Substitute {}, {}, and {} for great justice."
final_string = template.format('all', 'your', 'base')

For what it's worth, %SCANRPL might not just be used for templating.
It's a general string function, and it's easy to find cases where you
only want to replace one instance of whatever you're scanning for.
When you are in a code editor, and you do a find-and-replace, do you
ALWAYS replace all?

John Y.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].