Qlik Community

Ask a Question

Qlik Sense App Development

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

Announcements
Qlik Users, make your voice heard! Participate in Wisdom of Crowds® Market Study: Start Survey
cancel
Showing results for 
Search instead for 
Did you mean: 
marcel_olmo
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
sunny_talwar

How about doing just this

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

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>') , '>' , '<' )

petter
MVP
MVP

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>')

marcel_olmo
Partner
Partner

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

Regards, Marcel.