Tuesday, August 20, 2019

#1 2019-07-18 06:50:18 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5825

[ANN]: Script library for regular expressions, text manipulation

RegexAndStuffLib is a script library providing some basic string manipulation commands. There are commands for changing case, splitting and joining strings, various encoding and decoding commands, a range of regular expression commands, and more. It has a dictionary of terminology, to make it simple to use. You can download the library and documentation here:

https://www.macosxautomation.com/apples … ndStuffLib

A few of the commands should be useful for people who have relied on Satimage.osax.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#2 2019-07-19 02:25:37 am

ldicroce
Member
Registered: 2017-11-25
Posts: 124

Re: [ANN]: Script library for regular expressions, text manipulation

Thanks a lot, Shane!!!

Offline

 

#3 2019-07-21 11:33:09 pm

TMA
Member
Registered: 2005-11-24
Posts: 63

Re: [ANN]: Script library for regular expressions, text manipulation

Great, many thanks!

Offline

 

#4 2019-07-21 11:56:14 pm

CK
Member
From:: UK
Registered: 2018-11-04
Posts: 97

Re: [ANN]: Script library for regular expressions, text manipulation

I hope to see more libraries following this naming trend.

  - MathsPlusOtherBitsLib
  - StringsAndRantsLib
  - ListsNShitLib

Offline

 

#5 2019-07-22 04:57:33 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4940

Re: [ANN]: Script library for regular expressions, text manipulation

Shane Stanley wrote:

A few of the commands should be useful for people who have relied on Satimage.osax.


One difficulty with this claim is that the library uses different keywords and parameters from Satimage, so anyone who's relied on Satimage in the past will have to learn new stuff. This being so, they might just as well learn the relatively simple underlying AS and ASObjC commands, which have been available to scripters for some time now. It would both empower them and reduce the incidence of non-standard and occasionally non-sensical terminology in scripts, which would in turn make the scripts easier for others to understand and increase the chances of people who need help with scripts actually receiving it on the fora.


NG

Offline

 

#6 2019-07-22 06:52:05 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5825

Re: [ANN]: Script library for regular expressions, text manipulation

Nigel Garvey wrote:
Shane Stanley wrote:

A few of the commands should be useful for people who have relied on Satimage.osax.


One difficulty with this claim is that the library uses different keywords and parameters from Satimage, so anyone who's relied on Satimage in the past will have to learn new stuff.



I think that's a straw-man argument. A lot of people have used Satimage.osax primarily for regular expressions and stuff like case conversion, and the library simply provides some of those functions. I made no claim of similarity in implementation.

This being so, they might just as well learn the relatively simple underlying AS and ASObjC commands, which have been available to scripters for some time now.



I wrote a lot of it initially for myself -- I think I understand the underlying commands reasonably well, but I still appreciate convenience. And especially in terms of editing older code, there's a lot to be said for keeping ASObjC code separate.

That said, the code is all there for people to read, use and adapt, and similar code for much of it has been posted here many times already, often by me, for those who want to learn it. I suspect you overestimate people's enthusiasm for learning stuff like ASObjC (something I've obviously been guilty of too).

It would both empower them and reduce the incidence of non-standard and occasionally non-sensical terminology in scripts



If you have suggestions for improving the terminology, I'd welcome them. But I'm struggling to understand what "non-standard" means in this context. I mean, unless I've missed something, |⌘| is a little off the beaten track wink

which would in turn make the scripts easier for others to understand and increase the chances of people who need help with scripts actually receiving it on the fora.



I've read that several times, and each time I think I know what you mean, I suspect I've misunderstood. A script that uses commands and parameters documented in a standard scripting dictionary is harder for a scripter to understand than blocks of essentially Objective-C code re-written in verbose AppleScript?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#7 2019-07-24 06:48:00 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5825

Re: [ANN]: Script library for regular expressions, text manipulation

FYI, Version 1.0.2 is now available.

This version introduces performance improvements. In particular, the regex search command is faster — significantly so if you specify a replace template, or capture groups is either unused or a single integer.

Available same place, same name.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#8 2019-07-25 01:32:43 am

akim
Member
Registered: 2010-04-04
Posts: 101

Re: [ANN]: Script library for regular expressions, text manipulation

Shane, I have found your RegexAndStuffLib to be very helpful and instructive. However, my attempt to convert a list of strings to upper case erred.

Applescript:

use scripting additions
use script "RegexAndStuffLib" version "1.0.2"
set capsText to uppercase from {"one", "two", "three"} --> "The variable theString is not defined."

In your RegexAndStuffLib.scptd, v 1.0.2, modified July 24, 2019 at 5:40 PM, as listed in  Finder's Get Info, on line 54, I noted

 return (theString's valueForKey:"localizedUppercaseString") as text

I, however, could not find a prior definition of the theString variable. Could that be the reason for the "uppercase from" command to err?
I noted similar parallels to this line of code utilizing theString in other parts of your RegexAndStuffLib.scptd.

Of no scripting importance, but while I was reading your script, I noted that the Description heading remained as RegexAndStuffLib v1.0.1 rather than v.1.0.2.This was of no scripting concern, but might be of interest in keeping readers from confusing versions.

In any regard, thank you for instructing all of us to be better Applescript coders.

Offline

 

#9 2019-07-25 01:44:07 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5825

Re: [ANN]: Script library for regular expressions, text manipulation

akim wrote:

my attempt to convert a list of strings to upper case erred.



Yes, the list-handling code is borked because of last-minute changes. Version 1.0.3 is now available, with the problem fixed. Let me know if you find any other issues. Thanks.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#10 2019-08-05 06:24:06 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5825

Re: [ANN]: Script library for regular expressions, text manipulation

FYI, Version 1.0.4 is now available. Itfixes a bug in the regex search once command, where it returns an array rather than a list when multiple capture groups are specified.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)