[TAG] Filters
Jimmy O'Regan
jimregan at o2.ie
Sat Apr 17 13:39:47 MSD 2004
Ben Okopnik wrote:
>On Sat, Apr 17, 2004 at 12:01:12AM +0100, Jimmy O'Regan wrote:
>
>
>>During my 6 months without 'net access I read quite a lot of books,
>>including Trainspotting, and thought it'd be fun to write a filter.
>>
>>===== CUT HERE: trainspotting.sed.txt =====
>>s/ of / ay /g
>>s/ off/ oaf/g
>>s/ I / ah /g
>>
>>
>
>Nice. However, you should run a filter over your filters:
>
>sed 's#/ #/\\b#1;s# /#\\b/#1;s/ //g' trainspotting.sed.txt
>
>or something similar, anyway. :) The reason is that (for, e.g., the
>first expression) an 'of' at the beginning or the end of a line will be
>ignored - there's no space before it at BOL, and none after it at EOL.
>'\b' is a word boundary, which will do the right thing.
>
>
I didn't get that far into the sed manual :(. I was going to use perl
first, but I got caught up in the manpages. I'm still working on it, but
it got a laugh from a friend of mine, so I sent it in as it was.
More information about the TAG
mailing list