Advanced query - exclude blocks where matched content (regex) is page

This query picks up all blocks with lit references (matching the input regex). I’d like to exclude blocks where the lit reference is a page - so it’d pick up @Test2024 but not [[@Test2024]]. Not sure how to approach this and would love guidance. Part of me wonders - is this even possible?

{:title "References without pages"
[:find (pull ?block [*])
:in $ ?input
[(str "(?i)" ?input) ?pattern]
[?block :block/content ?content]
[(re-pattern ?pattern) ?captured]
[(re-find ?captured ?content)]]
:inputs ["@[a-zA-Z]+\\d{4}"]
1 Like

Welcome. Try :inputs ["(^|[^[])@[a-zA-Z]+\\d{4}"]

1 Like

Works perfectly thank you! Didn’t even think to try adapting the regex, oops.