Hi all,
I'm certain this has been thoroughly explained and I'd be happy to be pointed to the relevant thread but I can't find an answer or figure it out.
I'm trying to separate text using regex as a filter and I can't figure out the correct way to do it. The simplest case is that I want to separate text like the following into different variables:
Text and words.
Text and words.
Text and words.
Text and words.
Text and words.
Text and words.
I don't have to use regex for this, I'm open to any method. I've done it before using For Each and LocalIndex but I don't understand it well enough to modify it—I made it copying something from JMichealTX (may his good works live forever).
This problem comes up a lot so I'd really like to get a handle on it but I can't find anything that explains the For Each very well. The guide gives some info but leaves a lot out, imo.
Anyway, if anyone can help, I'd really appreciate it.
Did you know that there is a built-in way to separate the lines of a variable in keyboard maestro using the “Variable” token? I don’t think you need to separate them because they are already available as separate values using that token. Please read the largest paragraph of this page:
Thank you, that was helpful. I made some progress but can't figure out how to separate based on line breaks and although I was able to display text using periods as a separator I wasn't able to set new variables that way.
I think I'll have to give up on this solution for this project and look through the threads some more when I have a chance.
Keyboard Maestro is such a strange mix of intuitive and completely opaque—at least to me and it often feels like you have to understand the whole thing at once to get any of it to work.
Thank you. The Variable Token is great, I went over that page, several of the linked pages, tested /n /R, read up on those. Don't get me wrong, I'm definitely missing some key points, just not sure which.
Here is a version that I can't get to work with the kind of text I'm trying to manipulate. My guess is that there is not actually a hard return there but I don't know what to use as a separator if that is the case. Or maybe my syntax is bad?
No Problem! Depending on your needs, it could also be helpful to cycle through the lines of a variable with a "For Each" loop, and use an incrementing variable to store each line in it's own variable without using the variable indexes.