Forums > Max For Live

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

March 9, 2012 | 1:24 pm

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?


March 9, 2012 | 3:45 pm

[regexp]


March 9, 2012 | 5:32 pm

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

– Pasted Max Patch, click to expand. –

March 9, 2012 | 6:53 pm

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.

The difference is highlighted in this patch

– Pasted Max Patch, click to expand. –

March 9, 2012 | 7:20 pm

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

-Ben


Viewing 5 posts - 1 through 5 (of 5 total)