import re

regex = r"^(\w+)(?:\/.*)?$"
test_str = ("Foo/Bar\n"
	"Foobar")
result = re.sub(regex, r'\1', test_str, 0, re.MULTILINE)

if result:
    print (result)