on 2024 Feb 14 7:26 PM
I have an input key that asks for a period (month and year) and would like to modify whatever the user enters so that it replaces the space between the month and year with %20 to use it as a parameter in the GET URL.
I'm just looking for general ideas on how to accomplish this. Any ideas and/or suggestions are gratefully requested.
Thanks!
Ron
Hello Ron,
You can achieve this with the usage of expressions. There are three approaches you can take:
1. Using the `toUrlEncoded` function like so: `$(.execution.input.text | toUrlEncoded)`. It will encode all special characters and is designed to be used in URLs.
2. Using the `toPercentEncoded` function: `$(.execution.input.text | toPercentEncoded)`. It is similar to the previous one, but replaces whitespace characters with %20 as in your request.
3. Alternatively, you can use the `sub/gsub` functions: `$(.execution.input.text | gsub("\s+"; "%20"))`. It will only replace whitespace characters with %20 without encoding the rest of the special characters like /, : etc.
Additionally, you can draw inspiration for the available functions (those we keep updated in the docu) from here.
Hope this helps. Let me know if you have any more questions.
Best regards,
Kostadin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.