Here's one approach, which might work for you depending on your
workflow. And all it takes is BBEdit.

1. Convert the file to one line per fortune by replacing newlines with
some special character, and the %'s with newlines.

2. Double each line with a distinctive character as a separator. So
now a line might look like this:

"Conservatives want live babies so they can raise them to be ^  dead
soldiers" ~Carlin%"Conservatives want live babies so they can raise
them to be ^    dead soldiers" ~Carlin

3. Use simple search and replace to delete stuff you don't like from
the beginning of the line. For unusual cases, just do it manually.

4. This is now your master fortune file. When you add a fortune, add
it to this file in this format.

5. To create the "real" fortune file, sort the master file normally,
and then search and replace to strip off the beginning fortune
(everything up to the % in my example), to add back the % separators,
and to replace the newline placeholders.

On Oct 18, 3:37 pm, "le...@gmail" <[email protected]> wrote:
> I have a fairly long fortune file (http://home.kreme.com/mysigs.txt)  
> that I would like to sort in alphabetic order, excepting leading  
> punctuation or supper common words like 'a', 'the', 'I', &c.
>
> I have two problems, one of which I think is trivial, so let's cover  
> that one first.
>
> I need to capture the entire 'fortune' from % %, but fortune files  
> don't have a leading % or a closing % at the file boundaries. Many of  
> the fortunes are multiple lines, and I do not want to muck up the  
> formatting when I sort.
>
> The second problem, of course, is excluding a list of words I consider  
> 'common' from the sort.  For example,
>
> "May the forces of evil become confused on the way to your house"
>
> I would have both 'the' and 'may' in my exclusion list, so that should  
> sort based on 'forces'.
>
> "If a pig looses its voice, is it disgruntled"
>
> would be sorted under 'pig'
>
> Ideas?  Probably a perl script, huh?
>
> --
> Mac OSX - Because making Unix user-friendly was easier than fixing
>         Windows.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---

Reply via email to