home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / shell / 4543 < prev    next >
Encoding:
Text File  |  1992-11-05  |  1.4 KB  |  47 lines

  1. Xref: sparky comp.unix.shell:4543 comp.lang.misc:3493
  2. Path: sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peter
  3. From: peter@ferranti.com (peter da silva)
  4. Newsgroups: comp.unix.shell,comp.lang.misc
  5. Subject: Re: Need script (awk/sed/...) to remove dashes and do initial caps
  6. Message-ID: <id.K_OU.BLD@ferranti.com>
  7. Date: 4 Nov 92 18:11:24 GMT
  8. Article-I.D.: ferranti.id.K_OU.BLD
  9. References: <1992Nov2.195646.27860@spectrum.xerox.com>
  10. Organization: Xenix Support, FICC
  11. Lines: 34
  12.  
  13. In article <1992Nov2.195646.27860@spectrum.xerox.com> kris.wbst129@xerox.com writes:
  14. > Here are some examples of what needs to be done:
  15. > hello-world => HelloWorld
  16. > helloworld => Helloworld
  17. > HELLOWORLD => Helloworld
  18. > HELLO-WORLD => HelloWorld
  19.  
  20. Here's a LEX program to do it.
  21.  
  22. %START WORD
  23. %%
  24. [A-Za-z]+ { trans(yytext, yyleng); BEGIN WORD; }
  25. <WORD>\-[A-Za-z]+ { trans(&yytext[1], yyleng-1); BEGIN WORD; }
  26. .    { ECHO; BEGIN 0; }
  27. \n    { ECHO; BEGIN 0; }
  28. %%
  29. #include <ctype.h>
  30.  
  31. trans(s, l)
  32. char *s;
  33. int l;
  34. {
  35.     int i;
  36.  
  37.     output(toupper(s[0]));
  38.     for(i = 1; i<l; i++)
  39.         output(tolower(s[i]));
  40. }
  41. -- 
  42. % Peter da Silva % 77487-5012 % +1 713 274 5180 % Har du kramat din varg idag?
  43. /M{moveto}def/H{newpath 0 19 M 0 6 R 4 -4 R 0 16 M 5 0 R 3 -3 R -4 0 R -3 3 R 8
  44. 8 M 0 5 R stroke}def/R{rlineto}def 24 24 scale 3 3 translate H newpath 10 6 M 2
  45. 2 R -4 0 R closepath stroke 20 0 translate -1 1 scale H showpage %    `-_-'
  46.