Find all strings matching a giving regex pattern in files in a directory (including all subdirectories)
Some improvements


Style

Please indent your file properly, since indentation is important in Python, those lines like


if path.isdir(pth):   res.update(regex_search(regex, pth))



Are frowned upon, instead do

if path.isdir(pth):
    res.update(regex_search(regex, pth))

Use glob for listing files in a directory

With Python3.5+ glob is the easiest way to list all files in a directory and subdirectory, before you should use os.walk() 
Use generators when appropriate

This will save some memory space, as it doesn't have to append to the temporary list all the time
Use argparse over sys.argv[]

Argparse is the module for CLI input, easy to use and has a ton of features I definitely recommend it!


Code

import argparse
import glob
import re
import os
import pathlib

def regex_search(regex, directory):
    for f in glob.glob(f"{directory}**/*.*", recursive=True):
        with open(f) as _file:
            for i, line in enumerate(_file.readlines()):
                if regex.search(line):
                    yield f"In file {f} matched: {line.rstrip()} at position: {i}"

def parse_args():
    parser = argparse.ArgumentParser(
        usage='%(prog)s [options] &lt;regex&gt; &lt;directory&gt;',
        formatter_class=argparse.RawDescriptionHelpFormatter
    )
    parser.add_argument('regex', type=str)
    parser.add_argument('directory', type=str)
    args = parser.parse_args()

    try:
        rgx = re.compile(args.regex)
    except Exception as e:
        parser.error('Regex does not compile')
    directory = pathlib.Path(args.directory)
    if not os.path.isdir(directory):
        parser.error('Directory is not valid')
    return rgx, directory

if __name__ == '__main__':
    regex, directory = parse_args()
    for match in regex_search(regex, directory):
        print(match)


Bonus Round!

grep is a Unix tool that can basically do this by default

grep -Hrn 'search term' path/to/dir


Where:


-H prints the matching line
-r Does a recursive search
-n prints the line number