Aw, looking at the filter reference, I would suggest escaping the backslash. So technically, you would end up with double backslashes:
"ga:pagePath=~/q-\\d+/.+",
See the linked page, section Filter Expressions:
Reserved characters — The semicolon, comma, and backslash must all be backslash escaped when they appear in an expression.
Hope this helps.