r/applescript • u/etzabo • Sep 23 '20
Converting string in brackets to one list variable while other parts of the string are left singular on the list
I’m working on a script that converts every character of a string to a list, but the parts of the string in brackets need to be put in one string variable on the list, so “ab[cd]" would be converted to {“a”,”b”,”cd”}. I already have the script converting the string to a list, I just need to know how to convert the bracket text.
1
Upvotes
1
u/[deleted] Sep 23 '20
Is the string length always 4?
Is there always just one set of two characters in brackets?
Is the bracketed set always at the end of the string?
How are you converting the string to a list? It would help if you showed your code.
1
u/sargonian Sep 24 '20
I'm sure there's a more elegant way with text item delimiters, but this seems to get the job done: