Page 1 of 1
Search and Replace Within a Variable
Posted: 08 Feb 2015 21:18
by ltplenus
Hi Martin,
I have a flow that sends the url of a voice search to my computer . To accomplish that im using the Autoremote plugin and EventGhost on my computer to receive the message and open the url.
The problem is that EventGhost doesn't like blank spaces at all so a search for '' auto magic'' turns into a search for ''auto'' only...
The search is been passed by a variable called ''avcommnofilter'' ( the variable is provided by the AutoRemote plugin ) and my question is: how to replace the spaces within the variable with a + ??? ( like: auto+magic)
Thank you !
Re: Search and Replace Within a Variable
Posted: 09 Feb 2015 22:00
by TheBrain1984
Action: Script
var_b = replace(var_a, "auto magic", "auto+magic")
OR
var_b = replaceAll(var_a, "auto magic", "auto+magic")
var_a is the variable that includes the string "auto magic" and var_b is the variable that get's the string with "auto+magic"
Re: Search and Replace Within a Variable
Posted: 09 Feb 2015 23:16
by ltplenus
How would i go about it TheBrain ??
Something like this ?
var_b = replaceAll(var_avcommnofilter, " ", "+")
Re: Search and Replace Within a Variable
Posted: 10 Feb 2015 11:51
by TheBrain1984
This will replace all Spaces to "+". If this is what you want, than oyur solution would be correct.
Re: Search and Replace Within a Variable
Posted: 10 Feb 2015 20:01
by Martin
It sounds like the text might be passed to the computer as part of an URL parameter. If this is the case, you would also have to escape some other characters like question marks and equal signs.
To do this you can use function var_b = encodeURLForm(var_a);.
Re: Search and Replace Within a Variable
Posted: 10 Feb 2015 20:53
by ltplenus
I've tried a few things without success. Could you guys explain in details or make the necessary changes for me ?
http://automagic4android.com/flow.php?i ... b953ac5a7a
Thanks !
Re: Search and Replace Within a Variable
Posted: 11 Feb 2015 20:23
by Martin
Sorry, I don't use the plugins used by your flow so I'm not really able to test the flow.
I assume that you could change the following line in the AutoRemote action plugin:
putString("message", "http://google.com/search?q={avcommnofilter}");
to
putString("message", "http://google.com/search?q={encodeURLFo ... mnofilter)}");
Re: Search and Replace Within a Variable
Posted: 11 Feb 2015 20:45
by ltplenus
WONDERFUL !
Thats a solution for all my problems related to Phone/PC communication !
Martin, where is the ''DONATE BUTTON'' my friend ?
I need to click it a few times