I want to find tags within tasks with the help of a regular expression:
description regex matches /#tasks/ZKSV\d[4]/
Things I have tried
The tasks:
- [ ] Test ZKSV 2025/2026 #tasks/ZKSV2526
- [ ] Test ZKSV 2024/2025 #tasks/ZKSV2425
The tasks query:
not done
description regex matches /#tasks/ZKSV\d[4]/
This code finds the task with the tag #tasks/ZKSV2425, but not the task with the tag #tasks/ZKSV2526. I don’t get why. If I change #tasks/ZKSV2526 to #tasks/ZKSV2425 in the same task, the task is found. I also escaped the forward slash, just to be sure. It didn’t make a difference.
The slash must be escaped in regex but as I tried with your tasks just now, I had even zero results.
I tried adding $ at the end and ^ in front, even .*? to match anything in front, and [0-9]{4} for the digits, nothing.
I didn’t restart Obsidian as I don’t want to lose my work now.
Could be some bug.
The nicer version of that regex do include escaping the forward slashes, so I’d use this regex all day:
description regex matches /\#tasks\/ZKSV\d{4}/
When you do \d[4} you’re matching against a number, followed by a character class, [...], consisting of the single character 4. What you really want is to limit the count of the digits, through the use of {...}.