🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #518

regular expressions

#518
From: 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
Technical Details
Message-ID: <8908292100.AA00161@aurel.caltech.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfox
References: <3073@solo4.cs.vu.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfox
From: bfox@AUREL.CALTECH.EDU (Brian Fox)
Newsgroups: gnu.bash.bug
Subject: regular expressions
Message-ID: <8908292100.AA00161@aurel.caltech.edu>
Date: 29 Aug 89 21:00:21 GMT
References: <3073@solo4.cs.vu.nl>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: bfox@aurel.caltech.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 34