I am reading a book on RegEx and going over some of the challenges. I have just started to learn about capturing and non-capturing groups. So, anything above that, I cannot utilize in solving this problem. The person who wrote the book doesn't give you much information on the challenge questions. So, Let me show you the markdown then I will ask my questions:
CHALLENGE
Given a list of files in a directory (separated by newlines), identify which files have a vi swap file. vi swap files look like this: .filename.swp. So if there were a file in the directory called .favorite_regexes.txt.swp, you would want to include favorite_regexes.txt in your results.
- 
 should match.favorite_regexes.txt.swp .practice.py.swp .DS_Store favorite_regexes.txt practice.py zippy.py- favorite_regexes.txt
- practice.py
 
- 
 should not matchfile1 file2
END CHALLENGE
I am assuming the author is asking me to find any file ending in .swp but match the corresponding .txt file or maybe not? I can't tell.
For instance: I need to find .favorite_regexes.txt.swp but only highlight .favorite_regexes.txt in the list above?
I have been trying things like capture groups (.+)(.swp) and non-capture groups (.+)(?:.swp)  but it only highlights the entire .swp file. How would I go about finding the .swp file but highlighting the other?
Any help would be much appreciated, Matt
I
 
    