Thread View: gnu.bash.bug
4 messages
4 total messages
Started by Maarten Litmaath
Fri, 25 Aug 1989 16:12
regular expressions
Author: Maarten Litmaath
Date: Fri, 25 Aug 1989 16:12
Date: Fri, 25 Aug 1989 16:12
24 lines
932 bytes
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
Author: Brian Fox
Date: Tue, 29 Aug 1989 21:00
Date: Tue, 29 Aug 1989 21:00
34 lines
1288 bytes
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
Author: Maarten Litmaath
Date: Wed, 30 Aug 1989 15:35
Date: Wed, 30 Aug 1989 15:35
24 lines
1114 bytes
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
Author: Rayan Zachariassen
Date: Wed, 30 Aug 1989 16:49
Date: Wed, 30 Aug 1989 16:49
31 lines
1083 bytes
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