Please excuse my broken English but I will try my best with Google Translation.
I've got a variable like "abc123-456" and I want to extract the numbers but separately like this "123" "456" and these numbers can be one digit to 4 digit numbers like "1-1234" "12-1" "1234-10" "1234-1234".
So I want results such that if I have "text1233-111" set in my any variable I want to insert text or type like "text" "1233" "111".
I never done programming before and Keyboard Maestro is my first actual programming app. Any help would be greatly appreciated!
In a scripting language like Python (general purpose) or JavaScript (web + macOS/iOS scripting), we can typically "group" a sequence of characters into separate groups, according to whether they are numeric characters (digits) or not.
In Python, for example:
groupby("text1233-111", str.isdigit)
which we could generalize a bit:
for n in [
int(''.join(characters)) for (isnumeric, characters)
in groupby(test, str.isdigit)
if isnumeric
]: print(n)
and use in a Keyboard Maestro "Execute a Shell Script" action (example below).
Given that regular expressions do, as Chris puts it, "take a fair bit of learning", opinion will differ over whether the time and effort of learning is better rewarded by "regex" or by a fuller and more flexible scripting language.
My personal advice would probably be to learn the basic concepts of a general scripting language, before you dive into the less flexible and less powerful sub-language of regular expressions.
Separately grouping numeric and non-numeric characters
Thank you so much for your kind reply. I did a search on regex, but most of them are in English and my programming language skills are very low, so it was difficult to understand utilize so I needed an example. And you gave me perfect example! Thank you, thank you. Have a good day!
Thank you for your such a detailed kindness reply!
To be honest it does not look so easy to me but I will look up all of your examples and try to study properly thank you for the personal advice and I will try to learn basic concepts to!
To be honest, unless you happen to find them interesting in themselves, there are much better things to do in life than going down the rabbit hole of formal languages.
Usually better to get someone else to do it, if you can
(See under David Ricardo and trade theory – always best to spend the time where you can make the most of it)