Hide tag text from Dataview list

What I’m trying to do


I have a query that returns a list of all bullet points tagged with #quote and #fav:


LIST Lists.text
FROM #quotes and #fav
WHERE !contains(file.name, "Template") 
FLATTEN file.lists AS Lists 

I am trying to display the resulting test without the “#quote” and “#fav” displaying at the end, but cannot figure it out. Does anyone have any ideas?

Any help is much appreciated!


You could try something like the following:

LIST replace( replace( item.text,
  "#quote", ""),
  "#fav", "") 
WHERE !contains(file.name, "Template")
FLATTEN file.lists as item

Note however that also meddles with tags like #favorite if you happen to use it… Depending on how you write your list items, you could possible add a space in the search pattern.

The query essentially does a replace() on an already replaced string in order to get two replacements. This pattern could be extended further with more lines if you want to replace more stuff.

An alternative is to use regexreplace() where we can also check on word boundaries using \b, and then the query looks like this:

LIST newText
FLATTEN file.lists as item
FLATTEN regexreplace(item.text, "#(quote|fav)\b", "") as newText
WHERE !contains(file.name, "Template")

Here I’ve also used an extra FLATTEN to illustrate how we can keep the result in another variable, newText. If you prefer, you could do LIST regexreplace(...)


This worked, thank you very much for your help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.