How I can change whitespace in string to URL %20 sign?

sonykuba's icon

I have string with space in it and I want to send it via jit.uldl but i am having trouble to encode white space and sending it. Is there a way to replace all white spaces with given char set?

big_pause's icon

[regexp]

Ben Bracken's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You can use [\W]* and the @substitute attribute of regexp. Notice how you have to "escape" the '%' sign with another one:

big_pause's icon

disagree, I'd use [regexp \s @substitute %%20]

(\W)* will match any non-word character (eg "-"), and replace multiple successive occurrences by just one %20.

Max Patch
Copy patch and select New From Clipboard in Max.

The difference is highlighted in this patch

Ben Bracken's icon

big_pause, big ups. \s is the better way to go.

-Ben

keepsound's icon
Max Patch
Copy patch and select New From Clipboard in Max.

In your way you become a dobled % sign