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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

String manipulation

Hi all!

I have decoded what a user searches for, from an url adress in a large logfile. The result looks like this:

Skjermbilde.PNG.png

As you can see: space='%20' and the 'ø' char='%C3%B8' and so forth.

Is there an easier way to do this than replace() for each code I want to replace?

best regards

Trond Erik

Labels (1)
3 Replies
swuehl
Champion III
Champion III

Look into the mapping functions,especially the mapsubstring function:

The MapSubstring function is used to map parts of any expression to a previously loaded mapping table. The mapping is case sensitive and non-iterative and substrings are mapped from left to right. The syntax is:

mapsubstring('mapname', expr)

This function can be used for mapping parts of any expression on a previously loaded mapping table. The mapping is case sensitive and non-recursive. The substrings are mapped from the left to the right. Mapname is the name of a mapping table previously read by a mapping load or a mapping select statement (see Mapping). The name must be enclosed by single straight quotation marks. Expr is the expression whose result should be mapped by substrings.

Examples:

// Assume the following mapping table:

map1:

mapping load * inline [

x, y

1, <one>

aa, XYZ

x, b ] ;

MapSubstring ('map1', 'A123') returns 'A<one>23'

MapSubstring ('map1', 'baaar') returns 'bXYZar'

MapSubstring ('map1', 'xaa1') returns 'bXYZ<one>'

Not applicable
Author

Thank you! Just what I needed.

This community never dissapoints

rbecher
Partner - Master III
Partner - Master III

Hi Trond Erik,

I think it could be useful to load the whole W3 reference:

URL_Encoding_Reference:

LOAD

     Text([URL-encoding]) as URL_encoding,

     Replace([ASCII Character], 'space', ' ') as ASCII_Character

FROM

[http://www.w3schools.com/tags/ref_urlencode.asp]

(html, utf8, embedded labels, table is @1);

..store it as QVD and use it as MAPPING LOAD later for MapSubstr().

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine