Even I was searching for about an hour now I wasn't able to find an answer. I even read some Wiki articles but also without a match. Apologies if I missed something.
I like to search (and replace, but that's the easy part) for a number that varies in a text snippet and replace it with a particular variable that I created before. Basically it looks like this…
It will be possible to answer your query without having to guess/make assumptions if you would provide before/after examples of what you hope to achieve. Thanks!
Thanks for your reply and sorry @tiffle, I wasn't aware that I didn't make myself clear enough.
The text to find is exactly…
"parameterNumber": nn,
The "nn" stands for a number that can be 0, 53 or 457 - whatever. I assume that I don't know it before.
Before this action I already created the Variable called "E1 param ID" which contains the replacement for "nn". My goal then is to simply replace the whole text with the new one, containing the changed value taken from my prepared Variable.
My issue is to find the text string containing the unknown number "nn". So I wonder if I can use a kind of wildcard for "nn" to say the text is exactly like written except of something unknown for "nn".
Just one further point: I have assumed that the text you are searching includes the trailing comma. If that is an incorrect assumption you'll need to remove the "(,)" and the "$3" from the search and replace sections respectively.
If you'd like an explanation of the regex, let me know
Thanks so much @tiffle for your help and even creating the ready-to-go action. This is awesome. It worked immediately like I needed it.
Thanks also for the offer. But this would be probably really wasted time. I really wish I had more time to investigate more in regex but unfortunately I don't. And starting exactly from zero with also no experience in scripting and these topics around it is - at least for me - by far not easy to understand and adapt for even "simple" cases like this.
Thanks again for your help! Highly appreciated! I remember that you had helped me quite some times now.
I'd wish I also could offer more help. But during the last years I feel that it went more and more into a level that needs excellent skills in regex, scripting, development experiences and so forth.
In the meantime I have the impression that a lot of answers are containing scripts or referring recommendation to use them. And this is nothing I can help nor like to work with. It even gives the feeling that sometimes stops me from asking a question from the bottom of the "mouse-macro-division".
My feeling is that this is a reflection of the questions being asked -- sometimes you can solve the problem "within" KM but in a really convoluted way, but often the scripts are required because the solution extends beyond what KM can do natively. IMO, this is a bonus -- KM can do a lot itself and you can go beyond when you need to.
As to regex -- you don't need much beyond the basics to really expand your KM search-and-replace horizons. . means "any character" -- there's the "wildcard" you asked for. But regex can be more precise -- you were looking for digits so @tiffle suggested \d, which means any digit , and because you don't know how many digits there will be he followed with + which means "one or more of the previous thing". So \d+ matches "one or more digits".
Basic regex really is that simple, and you can pick up what you need as you go.
Please, please never think that! Speaking selfishly, I know a bit about scripting but I'm a total KM newb -- we bottom of the "mouse-macro-division" people need to stick together! And even the smartest macro writer can often gain from answering a "simple" question -- as the saying goes, the best way to understand something is to explain it to someone else.
I totally agree that this is a bonus. But from the bottom of the "mouse-macro-division's" perspective I'm very often not even able to get what's being answered. And to my impression this has definitely changed in the recent years. I even sometimes ask to not answer my questions with a script solution because I am not able to maintain that on my own, in addition maybe after a long time.
In my case it's definitely not the missing willingness to learn something new. It's just that I need to focus on my main work and not have the time to spend to "play" with macro possibilities just for themselves.
Thanks a lot for the description. Indeed it sounds simple in this example. But all regex sites I visited so far which have been recommended didn't help me to get into it even not for the basics. And of course it is also a matter of time.
I really like your kind words and it's true. Only what one is able to explain is something he really understood. So let's stick together and see what the future will bring…