I have a view that fetches a Belgian postal code, which always has 4 digits, from the URL and uses it as contextual filter to only show nodes for that postal code. This works fine.

I would like to also show sub-localities in this view. Given a postal code equal to 9990, the view should show the node for 9990 but also the nodes for 9991 and 9992, and other nodes whose postal code's first three digits are 999.

Is it possible to use the regex operator in the view filter for this, for example REGEXP_EXTRACT(%,"^.{0,3}") which doesn't actually work?

Preferably I'd like to solve this in the view itself and not with code.

1 Answer 1


Views Custom Regex

Module VCR has a String filter according to the code which maybe help using Start with.

Views Contextual Filter Validator: Regular Expression (regex)

Maybe usefull to validate the input?

You cannot use Views Contextual Filter Validator: Regular Expression (regex) as it is a validator only as explained in Can the regex extract portion of filter value for use?

Views Contextual Filter Validator: Regular Expression adds a Views contextual filter validator that can evaluate an argument based on user-supplied regular expression pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.