Caridad: thanks, but in this I don't have control of the source data. Sure it is possible to modify the database directly or using a meta field filter - but I was wondering if it is possible to solve it using a substring matching in the template.
If not, it's fine - but since the feature could also be useful in many other cases (not directly related to urls).
Just to make sure - there is no way to do a substring matching using wpv-if?
No, there isn't. I can only see the empty() function working in there. What you can do is to attach to a filter and do the evaluation yourself, something like this should work in functions.php of your theme: