I'm not sure I have fully understood but...
OQL uses a JavaScript based expression language so you can employ the following statement, it will find all objects which are inside the java.util.regex
package (recursively) and sum the sizes of them, it will return a single number:
sum(filter(heap.objects(), "/^java.util.regex./(classof(it).name)"), 'rsizeof(it)')
This will take same time, I have tested in only only on small heaps. Mind the ^
at the beginning of the package name.