pythonregexparsing

Trying to search for a certain pattern in text file


Okay so in Python, I'm trying to search for the pattern "comma, space, any lowercase character", but I cant get a regular expression that seems to work. The whole regular expressions thing is pretty new to me and I have no idea what I'm doing. I was able to search for a "number, space, any character using "[1-9]+ [a-zA-z]", but I'm not sure how to search for the pattern mentioned above. The picture included is an example of what pattern I am trying to search for in the text file.

Thanks, Schulzy

picture of text file


Solution

  • A Regex expression that would work is
    , [a-z]
    the comma and space are matched exactly, and the '[]' is a group, where anything in the group could be matched. you want any lowercase char's, so we put [a-z] for any character between lowercase a to z.