The following example was generated in a Reddit discussion and would make an excellent example for the repo:
import streamexpect
from subprocess import Popen, PIPE
pipe = Popen(r'net accounts', shell=True, stdout=PIPE).stdout
with streamexpect.wrap(pipe) as stream:
match = stream.expect_regex(r'Computer role:\s+(\S+)')
print('Computer role: ' + match.groups[0])