Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I hope I'm not posting this twice (sorry) I can't find that I hit send. So working with a nightmare file and our partner wrote a script, not in QS - but it looks like HTML (maybe?) that returns some string fields with a few extra characters. They look like HTML (like <b> and </b> for bold).
Anyways there's a line that uses the replace comment and it's not working.
I've tried changing the ampersand (&) and the semi-colon (;) to their ASCII and that does nothing. I can't use purgechar because I still need the letters (n,b,s,p and b). Suggestions for this new-ish Qlik Cloud user?
Here's the line of Code:
Replace(Replace(Replace([Answer Name], ' ',' '),'<b>',''),'</b>','') AS [Answer Name]
Suggestions welcome and thank you in advance!
To remove HTML tags from a string in Qlik Cloud, your approach using the Replace
function is correct, but it might need some adjustments depending on the tags you're encountering. The Replace
function works by sequentially replacing one string with another, so chaining multiple Replace
calls is a valid way to strip out multiple unwanted elements.
Here's a step-by-step breakdown and a refined approach: check innovative CBD
Nested Replace Functions: You're already using nested Replace
functions, which is good. However, ensure that all potential HTML tags are accounted for. For example, if there are other tags like <i>
, <u>
, etc., you would need to include them in the sequence.
Handling Other HTML Entities: If there are other HTML entities (like
), ensure they are all addressed. If you have multiple entities, you can keep chaining Replace
functions.
Alternative Approach with PurgeChar: If you're dealing only with specific HTML tags and no other special characters, PurgeChar
can help remove specific unwanted characters or patterns without removing the characters you want to keep.
Here’s your code with a more comprehensive approach:
Replace(
Replace(
Replace(
Replace([Answer Name], ' ', ' '),
'<b>', ''
),
'</b>', ''
),
'<i>', ''
) AS
You can keep adding Replace
functions as needed for other tags.