I found a possible solution. It uses gvpr, which is already installed if you have graphviz (at least it was on my machine).
You can configure gvpr to read the .dot file, follow some instructions and create another .dot file.
So, I added the property โtag =โ TAGfoo TAGgoo TAGsoo. โThere are probably better ways, but since I need to use a regex, this works pretty well.
Then the command:
gvpr -i 'N[tag=="(*TAGfoo*|*TAGgoo*)"]' filesource.dot >fileproduced.dot
will take all and only nodes with TAGfoo or TAGgoo.
It can be made cleaner.
source share