home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4293 < prev    next >
Encoding:
Text File  |  1992-08-13  |  928 b   |  45 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!pipex!warwick!coventry!ccx018
  3. From: ccx018@cch.coventry.ac.uk (Leslie Griffiths (Griff))
  4. Subject: A regexp quickie
  5. Message-ID: <BsyqJs.HIz@cck.coventry.ac.uk>
  6. Summary: How to express a certain pattern
  7. Keywords: regexp.
  8. Sender: news@cck.coventry.ac.uk (news user)
  9. Nntp-Posting-Host: cc_sysh
  10. Organization: Coventry University
  11. Date: Fri, 14 Aug 1992 07:38:15 GMT
  12. Lines: 31
  13.  
  14. Hi folks, I have a quick regexp query. Does anyone know how one would express
  15. the regexp 'a word, surrounded either by whitespace OR at the beginning of a
  16. line and ending in white space.'
  17.  
  18. e.g.
  19.  
  20. white
  21.  
  22.     or
  23.  
  24.     white
  25.  
  26. Its easy to express either of these
  27.  
  28. /^.*[     ]*/
  29.  
  30. and
  31.  
  32. /[     ][     ]*.*[     ][     ]*/
  33.  
  34. But how would one express both in a regexp.
  35.  
  36. NOTE - I am using sed, so no full regexps, no | or +
  37.  
  38. Cheers
  39.  
  40.  
  41. -- 
  42. Griff                \\             ccx018@uk.ac.cov
  43. ^^^^^                        :-=           ^^^^^^^^^^^^^^^^
  44.                     //
  45.