home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!crdgw1!rdsunx.crd.ge.com!ariel!davidsen
- From: davidsen@ariel.crd.GE.COM (william E Davidsen)
- Newsgroups: comp.unix.shell
- Subject: Re: Extracting regular expressions using egrep/sed/...
- Message-ID: <1993Jan6.140720.24207@crd.ge.com>
- Date: 6 Jan 93 14:07:20 GMT
- References: <1993Jan5.135145.28405@infolog.se>
- Sender: usenet@crd.ge.com (Required for NNTP)
- Reply-To: davidsen@crd.ge.com (bill davidsen)
- Organization: GE Corporate R&D Center, Schenectady NY
- Lines: 28
- Nntp-Posting-Host: ariel.crd.ge.com
-
- In article <1993Jan5.135145.28405@infolog.se>, mich@lin.infolog.se (Thomas Michanek) writes:
- |
- | I have two questions concerning csh programming:
-
- No, you have two questions about regular expression matching.
-
- | 1. Let's say I have a variable $var containing >1 words of text.
- | I want to know if this variable contains a specific pattern in the
- | form of a regular expression. The way I do it now is:
-
- The ':' operator in expr does this nicely and the status returned is 0
- for match and 1 for none, no checking of output needed.
-
- | 2. Now that I know the variable contains what I want, I want to extract
- | the part(s) of the variable value that matches the regular expression.
- | Let's say I'm looking for integers (i.e. [0-9]+) and $var contains:
-
- Again, expr has the ability to extract matching parts of complex
- regular expressions.
-
- | Any pointers are much appreciated!
-
- There is a lot more to expr than just arithmetic, and if you need
- portability it useful. As nice as ksh and perl are, it's nice to do
- things in a way which will work on all machines!
- --
- bill davidsen, GE Corp. R&D Center; Box 8; Schenectady NY 12345
- Keyboard controller has been disabled, press F1 to continue.
-