Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

replacing characters within a string

Hi,

I have a field I am creating in the LOAD section of my script using various formulae.

I need to be able to interrogate a string and replace any instance of "%20" and replace with " ", for example.

Thanks in advance,

Matt

3 Replies
Miguel_Angel_Baeyens

My untested guess is

Replace(Field,'%20',' ') AS Field


Not applicable
Author

Hi Matpj,

the function replace('abccde','cc','xyz') returns 'abxyzde' doesn't work for you need?

Best regards.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Replace() will work for the given example "%20", but if you have multiple sequences to translate, take a look at MapSubstring(). That will allow you build a table of substitutions and apply it in one pass.

Are you trying to unescape escaped strings like URLs? If so, an even easier way is to use the VB Script Unescape function. In your macro module, create a function like this:

Function un (str)
un = Unescape(str)
End Function

And then use it in your script like this:

un(url) as FixedUrl

-Rob