Use regex for shorter alias of heading links in dataview?

What I’m trying to do

Use regexreplace to shorten header links in dataview. Currently, dataview displays the entire header link (such as “02 Innate vs Adaptive Immunity > 01 Innate Immunity” which displays the “Page title > header title”). I want to use regex to only display “header title”

Things I have tried

TABLE WITHOUT ID regexreplace(file.folder, ".*\/([^\/]+)$", "$1") AS "USMLE Subject", file.link AS "Video Chapter", 
list(filter(file.tasks, (t) => t.completed AND contains(t.Course, "KF W2"))).section AS "Complete Topics",
regexreplace(list(filter(file.tasks, (t) => !t.completed AND contains(t.Course, "KF W2"))).section, ".*>\\s*") AS "Incomplete Topics"
WHERE file.tasks AND contains(file.tasks.Course, "KF W2")

It ended up in a parsing error. I’m pretty sure I put regex in the wrong place, but I’m not sure where to put it in such a long function. Any help would be much appreciated, thanks so much!!

I’m not here to stand between anyone and their regex. I just want to make sure you know that Dataview’s meta(link).subpath function returns the lowest-level heading as a string.

If flattening your tasks suits your query, you could use that string as the display text in the link to the task’s heading.

A quick example:

#chupachupsExample

~~~dataview
TABLE t.text AS "task text", meta(t.section).subpath AS "subpath", link(t.section, meta(t.section).subpath) AS "linked subpath"
FROM #chupachupsExample 
FLATTEN file.tasks AS t
~~~

## heading A
### heading A1
- [ ] task 1
- [ ] task 2
### heading A2
- [ ] task 3
## heading B
### heading B1
- [ ] task 4
### heading B2
- [ ] task 5

Paste the whole thing into a new note.

This is great thank you so much!! Would you know how to fit the meta function into my existing line? I’d like to keep this because of the filtering function, but of course if there’s a way to keep that within your link function I’d love that too.

list(filter(file.tasks, (t) => t.completed AND contains(t.Course, “KF W2 D4”))).section AS “Complete Topics”

that’s what I have so far as built in filtering

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