🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by Maarten Litmaath Fri, 25 Aug 1989 16:12
regular expressions
#510
Author: Maarten Litmaath
Date: Fri, 25 Aug 1989 16:12
24 lines
932 bytes
I've always wanted to be able to do something like the following:

	case $domain in
	\(.*\)\.\(.*\)\.edu)
		department=\1
		university=\2
	*)
		# ...
	esac

instead of

	case $domain in
	*.*.edu)
		department=`echo "$domain" | sed 's/\([^.]*\).*/\1/'`
		university=`echo "$domain" | sed 's/.*\([^.]*\).edu/\1/'`
	*)
		# ...
	esac

You get the idea.  Is this possible with bash?
-- 
"rot H - dD/dt = J, div D = rho, div B = 0, |Maarten Litmaath @ VU Amsterdam:
rot E + dB/dt = 0" and there was 7-UP Light.|maart@cs.vu.nl, mcvax!botter!maart
regular expressions
#518
Author: Brian Fox
Date: Tue, 29 Aug 1989 21:00
34 lines
1288 bytes
   Date: 25 Aug 89 16:12:23 GMT
   From: maart@star.cs.vu.nl  (Maarten Litmaath)
   Organization: V.U. Informatica, Amsterdam, the Netherlands
   Sender: bug-bash-request@prep.ai.mit.edu

   I've always wanted to be able to do something like the following:

	   case $domain in
	   \(.*\)\.\(.*\)\.edu)
		   department=\1
		   university=\2
	   *)
		   # ...
	   esac

   instead of

	   case $domain in
	   *.*.edu)
		   department=`echo "$domain" | sed 's/\([^.]*\).*/\1/'`
		   university=`echo "$domain" | sed 's/.*\([^.]*\).edu/\1/'`
	   *)
		   # ...
	   esac

   You get the idea.  Is this possible with bash?

Well, not without changing the semantics of the "case" command, and
writing a regular expression parser into the shell.

The pattern matcher is a globber, not a RE parser.  Sorry.

Brian
Re: regular expressions
#520
Author: Maarten Litmaath
Date: Wed, 30 Aug 1989 15:35
24 lines
1114 bytes
bfox@AUREL.CALTECH.EDU (Brian Fox) writes:
\...	   case $domain in
\	   \(.*\)\.\(.*\)\.edu)
\		   department=\1
\		   university=\2
\	   *)
\		   # ...
\	   esac
\...
\Well, not without changing the semantics of the "case" command, and
\writing a regular expression parser into the shell.
\
\The pattern matcher is a globber, not a RE parser.  Sorry.

Of course; it was never my intention to use the (normal) `case' command for
my idea.  But perhaps a syntax extension would be worthwhile?

	ecase ... in
	...
	esace
[sic]
-- 
C, the programming language that's the same |Maarten Litmaath @ VU Amsterdam:
         in all reference frames.           |maart@cs.vu.nl, mcvax!botter!maart
Re: regular expressions
#522
Author: Rayan Zachariassen
Date: Wed, 30 Aug 1989 16:49
31 lines
1083 bytes
>   Date: 25 Aug 89 16:12:23 GMT
>   From: maart@star.cs.vu.nl  (Maarten Litmaath)
>   Organization: V.U. Informatica, Amsterdam, the Netherlands

>   I've always wanted to be able to do something like the following:

>	   case $domain in
>	   \(.*\)\.\(.*\)\.edu)
>		   department=\1
>		   university=\2
>	   *)
>		   # ...
>	   esac

>   instead of ...

You will obviously like the ZMailer configuration language: a modern shell
with exactly this extension (originally in the case statement but it will
be a 'sift' statement in the next version).  Oh, and the way to write it
is

sift $domain in
(.)\.(.)\.edu)
	department=\1
	university=\2
	;;
tfis

because I use token-based REs.

rayan
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads