import re

strings = [
	r"C:\temp\John Smith Junior\file.pdf",
	r"C:\temp\John Smith Junior\John Smith Junior\file.pdf",
	r"C:\temp\John Smith Junior file.pdf"
]

for s in strings:
	m = re.match(r".*?\bJunior\b(\\)?(?(1)|.*)", s)
	if m:
		print(m.group())