home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / shell / 5272 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.7 KB

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