Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
See why Qlik is recognized as a Leader for the 10th year in a row – and discover how Qlik can help put your business in the lead. Get Report
Highlighted
Partner
Partner

Textbetween challenge

Hi guys,

I have to read some information inside two tags like the following :

<div id="main" class="class 1"> 10 </div>

If I do this :

TextBetween(MyField, '<div id="main" class="content 1">', '</div>')

I'll get my desired result, which is 10.

But sometimes the content of class is class 1, sometimes is class 2, or 3.

But, if I try this to include all the possibilities :

TextBetween(MyField, '<div id="main" class="content *">', '</div>')

it doesn't recognize the '*' to get a regular expression.

How could I do this?

Regards, Marcel.

Labels (2)
4 Replies
Highlighted

Re: Textbetween challenge

How about doing just this

TextBetween(MyField, '">', '</div>')
Highlighted
MVP
MVP

Re: Textbetween challenge

You mention regular expression - and Qlik doesn't support regular expressions ... although it supports wildcards in various contexts but not in the TextBetween() function.

 

TextBetween doesn't recognized tags at all just pure text so how about trying this expression:

    TextBetween( TextBetween( Field , '<div id="main" class="content ', '/div>') , '>' , '<' )

Highlighted
MVP
MVP

Re: Textbetween challenge

This should be even more exact:

TextBetween(
    Replace(Replace(Replace( MyField
        , 'class="content 1"' , '§' )
        , 'class="content 2"' , '§')
        , 'class="content 3"' , '§'
    )
    ,'<div id="main" §>', '</div>'
)


Or slightly less readable:

TextBetween(Replace(Replace(Replace( MyField,'class="content 1"','§'),'class="content 2"','§'),'class="content 3"','§'),'<div id="main" §>','</div>')

Highlighted
Partner
Partner

Re: Textbetween challenge

Thanks Peter! I've used your solution to make a workaround for my issue.

Regards, Marcel.