[1191] in Coldmud discussion meeting

root meeting help first previous next last

[COLD] Re: [ColdCore] Editor command sed/sub

daemon@ATHENA.MIT.EDU (Sun Dec 22 12:29:54 1996 )

From: silovic@srce.hr (Miroslav Silovic)
In-Reply-To: <Pine.NEB.3.95.961220232425.20830A-100000@glacier.cold.org> from Brandon Gillespie at "Dec 20, 96 11:27:56 pm"
To: brandon@glacier.cold.org (Brandon Gillespie)
Date: Sun, 22 Dec 1996 18:22:13 +0100 (MET)
Cc: coldcore@cold.org, coldstuff@cold.org

> In the editor there is the command that works like sed in unix:
>     s/.../.../yyy
> It is also modeled after the same MOO style command, with the range
> specified after the flags (yyy).  A question has arisen with the two
> available types of search and replaces, strsed() and strsub().  To specify
> the difference I created 'sub' and 'sed', ala:
>     sub/xxx/yyy/fff
>     sed/xxx/yyy/fff
> The question is what behaviour should 's' follow?  sed or sub?  I
> personally think sed--but I'm a regexp freak.  Others?  Note: sed gives
> you FULL sed capability, i.e.:
>     sed/(regex)more(regex)more(regex)/other%1more%3baz%2/
> Where sub is simply a literal translation.  I would consider nixing sub
> all together if it weren't for the 'magical' characters you don't always
> want to be escaping, namely []*$() and company..
> Preferences?
> -Brandon Gillespie

Okay, by now you prolly know just /who/ arose the question. MOO's
s/// is just a literal translation, and I muchly prefer it that way.
Common sense says that simpler feature (and that's non-regexp) string
substitution is much more common in Real World. So, s/// should follow
that semantics, with sed/// when you /really/ need it. After all,
regexp can be real pain in the ass when you want to replace
numeric expression in a method, plus, automation gained with
regexps is completely useless for JUST A SINGLE substitution that
most editor users really need (regexps are a norm when you use,
for instance, @grep with +r).