Malcolm McLean said:You can't do that and keep a secretarial job. Well actually you maybe can,
it's such an unusual response that a secretary who said that would probably
be treated as a company treasure. But usually, a businessman expects a
reasonable instruction like that to be executed.
If I were given such an instruction in the context of a secretarial
job, that would provide a great deal of information. You gave no
such context. I answered as a software developer, which you already
know is what I am.
You need to read the text. It's entirely possible that a blind search/replace
of the sequence "her" by "him" will produce an output everyone would
agree is the one desired. It's quite likely that a word replacement will
But it's also likely that no simple program can do the job, but any human
can, for example, "himself" and "herself", or "her" and "his". It's also
likely that there are other gendered words, there comes a point where
you've got to query if, say, "Freda" should be replaced by "Fred". That's
pretty clearly going beyond the instruction. It's hard to say where that
User requirements are often inherently ambiguous in computer terms.
There is no algorithm that can fulfil the businessman's request.
Ok, so we seem to be in agreement, now that you've provided some
But if we're talking about doing search-and-replace within a string
*as a programming problem*, the requirements can and should be
defined unambiguously. If I'm writing an implementation of sed,
for example, I'll be working from a specification that leaves no
doubt what should happen if there's an overlap.