Re: Alternative Syntax for Regular Expressions?

spinoza1111@yahoo.com (Edward G. Nilges)
20 Oct 2001 21:29:55 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: Alternative Syntax for Regular Expressions? dmitry@elros.cbb-automation.de (2001-10-12)
Re: Alternative Syntax for Regular Expressions? alexc@world.std.com (2001-10-13)
Re: Alternative Syntax for Regular Expressions? rboland@unb.ca (Ralph Boland) (2001-10-13)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-14)
Re: Alternative Syntax for Regular Expressions? eanders@cs.berkeley.edu (2001-10-16)
Re: Alternative Syntax for Regular Expressions? ralph@inputplus.demon.co.uk (2001-10-16)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-20)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-20)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-20)
| List of all articles for this month |
From: spinoza1111@yahoo.com (Edward G. Nilges)
Newsgroups: comp.compilers
Date: 20 Oct 2001 21:29:55 -0400
Organization: http://groups.google.com/
References: 01-10-029 01-10-072 01-10-078
Keywords: lex, comment
Posted-Date: 20 Oct 2001 21:29:55 EDT

eanders@cs.berkeley.edu (Eric Arnold Anderson) wrote in message news:01-10-078...
> > [ Edward Nilges complains that RE's are unreadable and proposes the use
> > of BNF.]
>
> Your example was:
>
> ^(\([0-9]{3}\)[ ]{1}){0,1}[0-9]{3}\-[0-9]{4}$ Yecchhhh
>
> If we were to translate this to Perl RE's directly, we would get (1):
>
> $regex = qr/^(\(\d{3}\) )?\d{3}-\d{4}$/;
>
> or if you want (2):
>
> $area_code = qr/\(\d{3}\)/;
>
> $regex = qr/^($area_code )?\d{3}-\d{4}$/;
>
> or even perhaps (3):
>
> $area_code = qr/\(\d{3}\)/;
> $local_number = qr/\d{3}-\d{4}/;
> $regex = qr/^($area_code )?$local_number$/;
>
> or if you want to decorate with comments (4):
>
> $regex = qr/^ # match at beginning of string
> ( # parenthesis to group together
> \(\d{3}\) # area code
> \ )? # separated by space, and optional
> \d{3}-\d{4} # local number
> $ # match at end of string
> /x; # /x makes it an extended regexp.
>
> or with the previously defined variables:
>
> $regex = qr/^ # match at beginning of string
> ($area_code )? # optional area_code
> $local_number
> $ # match at end of string
> /x; # /x makes it an extended regexp.


Cool!!


However, this is still too Perly for MIS. BNF uses a grand total of
ONE special symbol, the production operator (usually written as :=),
and this to me makes it easier to teach and use in MIS areas in
general and VB.Net in particular.


My agenda is the elimination of the perceived need to write the "hard
stuff" in Perl and the candy fluff in VB. I claim that given the
implementation of VB.Net we can do anything in VB.Net that was
formerly done in perl. This also avoids the need for the addition of
unix servers to run the advanced perl stuff.
[Um, you do know that there are full, free, versions of perl for Windows,
don't you? -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.