From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078708811611.tru64-unix-managers.marc@archive.invalid> From: Willig Reimund Date: Fri, 15 May 1998 10:58:21 +0000 To: tru64-unix-managers Subject: SUMMARY:why is the result of the regular expression in following X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078708811611 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