Re: Objective-C string replacement routine
Re: Objective-C string replacement routine
- Subject: Re: Objective-C string replacement routine
- From: Deivy Petrescu via AppleScript-Users <email@hidden>
- Date: Sun, 8 May 2022 14:36:06 -0400
> On May 7, 2022, at 15:13, Jim Brandt via AppleScript-Users
> <email@hidden> wrote:
>
> <snip>
> Because the $ is the regular expression character signifying the end of a
> search string,
> regex is not usable here. The Satimage change command could be use with or
> without regex,
> so my searches were without in this case.
>
> So, I’m trying to come up with an Objective-C replacement.
>
> Here’s what I tried:
>
> set V to {"$var$", "$label$", "$x$", "$y$", "$w$", "$h$", "$def$"}
> set TextBox to {"tb", "Label Text:", 0, 25, 300, 10, "Default Value"}
> repeat with i from 1 to count of V
> set EachV to item i of V
> set EachSub to item i of TextBox
> set SingleBoxText to (my substituteText:SingleBoxText searchFor:EachV
> replaceWith:EachSub)
> end repeat
>
> books I have don’t go too deep into string manipulation.
>
> Jim Brandt
Hi Jim
You’ve got some pointers which you should use.
However, if you allow me 2 other suggestions:
1. If you don’t have then get it BBEdit. They have a free version. Since I have
the paid version I am not sure if the free is scriptable.
However, scriptability is not the issue. They have a chapter (8) dedicated to
regular expressions, which I use as reference.
I’d really encourage you to read it. I have been able to make extremely
intricate substitutions because of it.
So, if you plan to use it, I strongly recommended.
2. Since you can use one inside the other (do script), be aware that JavaScript
have native regular expression commands.
This can also come in handy at times.
Best, be safe, wear mask, get vaccinated and keep social distance.
Deivy Petrescu
email@hidden
_______________________________________________
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