Re: If you were inventing CoBOL...

From: Michael Wojcik (mwojcik_at_newsguy.com)
Date: 09/13/04


Date: 13 Sep 2004 19:37:56 GMT


In article <qj81k01i45kfl7l4r5jo9n6l54q6jtkumb@4ax.com>, Robert Wagner <robert@wagner.net.yourmammaharvests> writes:
> On Thu, 09 Sep 2004 18:40:36 +0100, Frederico Fonseca
> <real-email-in-msg-spam@email.com> wrote:
>
> >And when it cames to doing regular expressions then there is no editor
> >like vi that I know of.

Actually, traditional vi (and POSIX / SUS vi) regular expression
support is limited. The BRE (basic regular expression) syntax used
by ex and vi doesn't support alternation (in the general case - it
supports limited forms), which makes it less expressive than formal
RE syntax and can, in fact, be a real pain.

This is another thing that vi clones often improve on. vim, for
example, uses "\|" to express alternation, similar to egrep; the
vertical-bar character is often used for alternation in formal syntax
as well, of course. vim's "regular expressions" actually include
syntax that makes them more powerful, in a strict and formal sense,
than real regular expressions. If you use a search in vi like:

   /\(a*\)b*\1

(which means "some number of a's, followed by some number of b's,
followed by just as many a's as you had before the b's") you've just
specified a language which is recursive but not regular; it requires
at least a push-down automaton to recognize it. It might be
possible with multiple \<number> expressions to specify a language
which is recursively enumerable but not recursive, making vim's
search capability more powerful than a PDA; I haven't given it much
thought.

> The regular expression processor in my editor is written in Cobol.

And indeed plenty of editors besides vi and its derivatives have
regular-expression searches, and some even have proper RE search-
and-replace, with the ability to select portions of the search text
in the replacement text. There was a time when RE search-and-
replace was an unusual feature, but these days it's pretty common.

-- 
Michael Wojcik                  michael.wojcik@microfocus.com
   O sometimes, nevertheless,
The labourer at his instrument or tractor,
Bending into a state of merge with objects,
Finds the same love that, from a machine of sex,
Steps down as Venus to her invoker.			-- George Barker


Relevant Pages

  • Re: Question about Sun JAVAC
    ... > The RE and ERE syntax used by various Unix utilities clearly was ... > Of course the symbols available for ASCII I/O devices (that is, ... > But traditional mathematical syntax for regular expressions happened ...
    (comp.programming)
  • Re: How to renumber files?
    ... > portion of the file name by the magic sed command whose syntax I don't ... nice reference for Perl-compatible regular expressions. ... > suppose I can try to make the script do this automagically for me. ... You can run NUM through a sed command ...
    (comp.os.linux.misc)
  • Re: How do I parse this string into int fragments?
    ... A good idea to use regular expressions for such parsing. ... Then you don't need to fiddle with the code too much when the syntax of the expression changes. ... Regex rx = new Regex; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: findobj -regexp documentation error?
    ... Limiting the Search with Regular Expressions. ... all stemseries objects that do not have their property Tag set ... rather than the syntax for "anything ...
    (comp.soft-sys.matlab)
  • Re: working storage values
    ... Of course the result of a grep can be piped into the ... editor so that the files can be accessed directly by tapping on the ... The difference between Windows and Unix is that Windows is designed for typical users, ... Google doesn't take regular expressions either, ...
    (comp.lang.cobol)