You can do this in ack:
echo -e "hello1, please match me\nhello2, please do not match me" > file ack --output "\$1" '(hello[0-9]+), please match me' file
prints
hello1