* SUMMARY:why is the result of the regular expression in following
@ 1998-05-15 10:58 Willig Reimund
0 siblings, 0 replies; only message in thread
From: Willig Reimund @ 1998-05-15 10:58 UTC (permalink / raw)
To: tru64-unix-managers
Hallo regular expressionists!
its really great how fast this supportline solves problems. As the
solution for my question i simply copy two mails, which were very
helpfull (thank you!!):
1. from Sam Nelson [Sam.Nelson@cs.stir.ac.uk]
The '\(' and '\)' brackets mean `return this part when matched'. The
stuff
inside the bracket means `an arbitrary-length string of non-digit
characters'
(that's the `[^0-9]*' part) followed by `an arbitrary-length string of
digits'
(that's the `[0-9]*' part). It looks as if what's happening is that
someone
is trying to turn a partition name (`rz14c' or something like that) into
the
name of the device the partition comes from, because the part that
wouldn't
be returned would be the guff at the end (`.*') is just `an
arbitrary-length
string of characters'). If you give that regular expression "rz14c" as
an
input string, for example, it returns "rz14".
I must admit that I (perhaps paranoiacally) use single quotes around
regular
expressions to guard them from `early interpretation'.
2. from Per Boussard T/ED [Per.Boussard@era-t.ericsson.se]
Here's a try..
(Hint: Check what expr "rz14" : "\([^0-9]*\)[0-9]*.*" and
expr "rz14" : "[^0-9]*\([0-9]*\).*" and=20
expr "rz14" : "[^0-9]*[0-9]*\(.*\)" returns)
expr will return what is between \( and \).
the first [^0-9]* will match any number of characters that are *not*
digits (note the '^'), hence it matches 'rz'. The next one is [0-9]*,
which will match any number of digits (hence '14'). The .* matches any
number of characters (including an empty set, which is the case here).
Remember that expr implicitly anchors the expression (i.e. there's a ^
in
the beginning and an $ in the end of the expression implied).
mit freundlichen Gr=FC=DFen
Reimund Willig
willig.reimund@gdr.de
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-05-15 10:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-05-15 10:58 SUMMARY:why is the result of the regular expression in following Willig Reimund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox