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