• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Text parsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text parsing


  • Subject: Re: Text parsing
  • From: Bill Monk <email@hidden>
  • Date: Tue, 2 Mar 2004 17:06:14 -0600

Thanks Emmanuel, that's extremely helpful.

Also Satimage, Smile, and SmileLab are beautifully done. I wasn't aware
of them before.

Anyway, with just a bit a tweaking, it is now working.

textA was selecting -all- interesting text, rather than -only- textA,
so I changed the textA & textB regexp slightly:

find text (sema & beforeA & textA & beforeB & textB) with regexp, string
result and all occurrences using {"\\1","\\3"}

sema: "\\[semaphore_word\\]"
beforeA: " *[0-9]{1,2}\\. *"
textA: "([^\\(]*\\>)" -- selects to end of last word before open paren
beforeB: " *"
textB: "(\(.*\))" -- selects parens and text between them


Naturally (of course) I -now- discover that some of the text chunks
contain TWO pairs of parentheses:

foo [person] 1. My Name (And Title) (And Address)
for [song] 11. Song Title (Sub Title) (Writer's Name)

For these rare items, the output is
{{"My Name", "(And Title) (And Address)"}}

but the desired output would be
{{"My Name (And Title)", "(And Address)"}}

Can a regexp be formed to (essentially) make an if-then-else decision
based on how many items it matches? This is at the outer limits of my
knowledge of grep and backreferences, so I'm studying man grep closely....

Obviously this is no longer an Applescript question! But again thanks for
the help and pointer to Smile.

Bill

>You've practically written the regular expression pattern yourself.
>
>I won't test that now, sorry, but I think that the "find text" command in
>the Satimage osax will do the job for you. Something by:
>
>find text (sema & beforeA & textA & beforeB & textB) with regexp, string
>result and all occurrences using {"\\1","\\3"}
>
>sema would be "\\[semaphore_word\\]"
>beforeA would be " *[0-9]{1,2}\\. *"
>textA would be "(.*)"
>beforeB would be " *"
>textB would be "(($)|\\((.*)\\)$)"
>
>Since the regular expression is so complicated, I would recommend testing
>everything from the "Find" (or "Enhanced Find") panel of Smile, since it
>uses "find text" itself.
>
>The Satimage osax and Smile are free software for AppleScript, to be found
>at:
><http://www.satimage-software.com>
>
>Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Run only in AS Studio?
  • Next by Date: Re: script doesn't find all the file in a hiearchy
  • Previous by thread: Re: Text parsing
  • Next by thread: Home directory
  • Index(es):
    • Date
    • Thread