Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Index of string '* ??-??? *'

Hi there,

I need to find an index of string '* ??-??? *' where question mark is a single digit and a star is any number of characters. 2nd and 3rd digits are seperated by a dash and there are spaces before 1st anf after 5th digit.


String: Berliner Str. 154 20-254 Chemnitz

Substring: 20-254

Result: 27

So far I used MapSubString replacing ??-??? with a special character and found the index but it happened that ??-??? appeared in another part of a string (e.g. String: Berliner Str. 146-148 20-254 Chemnitz; Substring: 46-148) and MapSubString won't work here as it can't cope with surrounding spaces (when mapping ' 46-148 ' MapSubString will actually map '46-148'). Any idea how to get that index?



4 Replies

Re: Index of string '* ??-??? *'

Przemek, could you post your current script snippet?

Valued Contributor III

Re: Index of string '* ??-??? *'

You may replace each digit with 'n' and then locate 'nn-nnn' using index() function

Not applicable

Re: Index of string '* ??-??? *'

I can't due to the problem described in the above example.

Not applicable

Re: Index of string '* ??-??? *'

I found a workaround - when loading data from a file instead of inline QV recognises surrounding spaces so I moved all MapSubString data to a file.

Community Browser