COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Tsunami on 02 Feb 2015 02:26:50 PM

Title: Expression to remove characters between specific characters
Post by: Tsunami on 02 Feb 2015 02:26:50 PM
I have data that comes over with HTML coding:


ex.

<p> Date </p>

How do I get rid of everything that is between <> including <> itself?  The example is super simplified.  The data comes w/ several HTML items.
Title: Re: Expression to remove characters between specific characters
Post by: keshavchhn on 03 Feb 2015 04:02:28 AM
For the mentioned example you can use:
substring([Dateitem],4,4)
it will give you Date.
Title: Re: Expression to remove characters between specific characters
Post by: Robl on 03 Feb 2015 04:54:42 AM
Try this

replace([yourstring], '<p>', '')
That should replace the <p> tag with a zero length string.
Then do it again for </P>

If there are loads of differen html tags then I'd be looking at doing something with a substring with locate < and locate > to determine which bits to cut out.
Title: Re: Expression to remove characters between specific characters
Post by: CognosPaul on 03 Feb 2015 06:22:37 AM
What data source is this? Some databases, like Oracle, have XML functions you can use. You might be able to do:
xmltype([Field]), and then use the extractValue() on that.

Title: Re: Expression to remove characters between specific characters
Post by: Tsunami on 04 Feb 2015 09:10:48 AM
Quote from: Robl on 03 Feb 2015 04:54:42 AM
Try this

replace([yourstring], '<p>', '')
That should replace the <p> tag with a zero length string.
Then do it again for </P>

If there are loads of differen html tags then I'd be looking at doing something with a substring with locate < and locate > to determine which bits to cut out.

good idea, think I can modify this to meet my needs...may be tedious but should be able to get it to work

This is a MS SQL datasource.