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

Mar 9, 2012 at 1:24pm

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

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?

#62259
Mar 9, 2012 at 3:45pm

[regexp]

#224926
Mar 9, 2012 at 5:32pm

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. –
#224927
Mar 9, 2012 at 6:53pm

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. –
#224928
Mar 9, 2012 at 7:20pm

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

-Ben

#224930

You must be logged in to reply to this topic.