Looks like wrapping `?pid` in `str()` suffices, so: `regex(str(?pid), '$search_value')`