Re: How to Do This Without Smile or Satimage
Re: How to Do This Without Smile or Satimage
- Subject: Re: How to Do This Without Smile or Satimage
- From: Rick Gordon <email@hidden>
- Date: Wed, 29 Feb 2012 02:34:17 -0800
Hmm, I've never used text item delimiters quite this way before. Let me see if I've got it:
The first assignment to OutputText (as text items) here is {"To ", " this one"}. Then the second assignment of OutputText is {"To ", " this one"} as text, with the delimiter as "flush", so when it is coerced to text, it becomes "To " & "flush" & " this one" = To flush this one"
But the bottom line is, that though the example that I posed didn't actually require regular expressions, but some other contexts where I'd like to apply this definitely do, and I'm quite comfortable using regular expressions.
I'm not seeing how this technique could be extended to fully use regular expressions, and to simulate the logic could be quite verbose. No?
Thank you, though, for providing that example. It's very useful for me to be aware of that as a possibility, and just to understand the potential of text item delimiters as multi-character strings.
Rick Gordon
------------------
On 2/29/12 at 9:23 AM +0100, Axel Luttgens wrote in a message entitled
"Re: How to Do This Without Smile or Satimage":
>Le 28 févr. 2012 à 11:40, Rick Gordon a écrit :
>
>> I'm looking for a way to implement regex operations to a string or variable without using Smile, Satimage, or some other external resource. I'm thinking that there must be a way to formulate this as a shell command (using perl -e, sed, or something), but what I'm finding seems to be that those things would be operating on a file, and I just want to act on passed strings (within the context of a repeat loop on targeted objects).
>>
>> tell application "Adobe InDesign CS5"
>> tell applied paragraph style
>> set vParaStyleNameIn to name as string
>> tell application "Smile"
>> set vParaStyleNameOut to uchange "indent" into "flush" in vParaStyleNameIn ¬
>> with regexp without case sensitive
>> end tell
>> end tell
>> end tell
>>
>> It seems so simple; there must be a way.
>
>Hello Rick,
>
>Still wondering why Shane's initial sugestion hasn't made its way... For example:
>
> on uchange(InputText, Match, ChangeTo)
> local TIDs, OutputText
> set TIDs to AppleScript's text item delimiters
> set AppleScript's text item delimiters to {Match}
> set OutputText to text items of InputText
> set AppleScript's text item delimiters to {ChangeTo}
> set OutputText to OutputText as text
> set AppleScript's text item delimiters to TIDs
> return OutputText
> end uchange
>
> uchange("To indent this one", "indent", "flush")
> --> "To flush this one"
>
>Do you have special requirements needing to resort to "do shell script"?
>
>Axel
--
___________________________________________________
RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________
WWW: http://www.shelterpub.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden