I love the command StringReplace. It's very simple and powerful. But I would like to see an addition to this command. How many times it should replace the string.
The current way is:
let>example=The apple is red. The sky is blue.
StringReplace>example,is,was,example
This returns:
The apple was red. The sky was blue.
What I'd like to see is:
let>example=The apple is red. The sky is blue.
StringReplace>example,is,was,example,1
Notice the addition of ",1" at the end of StringReplace.
This would indicate to replace only the first found string.
So your result would be:
The apple was red. The sky is blue.
This ofcourse is a very basic example. You may have a string of numbers and want to remove the first number that repeats more than once in the whole number. Such as 283628. You could replace the first, but not the second.
Also maybe to make it even more flexible add a START_AT_POS variable.
Suggestion / Request
Moderators: Dorian (MJT support), JRL
Suggestion / Request
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
Here is a method to study.
Code: Select all
//replace only first instance of pattern in string
Let>text=The apple is red. The sky is blue.
Let>pattern=....(is)....
RegEx>pattern,text,0,matches,num,0
StringReplace>matches_1,is,was,r2
Let>pattern=%matches_1%
RegEx>pattern,text,0,matches,num,1,r2,r
MessageModal>r
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
For just the first match:
Let>text=The apple is red. The sky is blue.
Let>pattern=^(.*?)is
RegEx>pattern,text,0,matches,nm,1,$1was,new_text
Let>text=The apple is red. The sky is blue.
Let>pattern=^(.*?)is
RegEx>pattern,text,0,matches,nm,1,$1was,new_text
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi adroege,
For examples, try a Google search for $1 against the forums and you'll get some interesting and relevant posts like these:
Capture group in RegEx?!
Converting capital letters to small letters
...and there are lots more... all from the forums... the "help file that writes itself".
Take care
That's probably because its a RegEx thing... not a Macro Scheduler thing.adroege wrote:Very clever with the $1 syntax -- however I could find no mention
of this in my help file!
For examples, try a Google search for $1 against the forums and you'll get some interesting and relevant posts like these:
Capture group in RegEx?!
Converting capital letters to small letters
...and there are lots more... all from the forums... the "help file that writes itself".
Take care
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Thanks
Thanks everyone.
I didn't know. Knowing is half the battle. G.I. Joe.
I didn't know. Knowing is half the battle. G.I. Joe.
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
On a side note
Just looked up RegEx on the web.
On a side note.....
I don't know what you people be smoking!!!!
But it MUST be DAMN GOOD!!!
Where can I get some of that?
On a side note.....
I don't know what you people be smoking!!!!
But it MUST be DAMN GOOD!!!
Where can I get some of that?
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!