@yuhunglin Thinking about this more:

- Instructors don't have the ability to contribute to the contents of this field. The line is 100% Canvas-generated and consists of "[person] submitted a late assignment [assignment name] in the course [course name]. Click here to view [url]." So there is not really the possibility that another accidentally matching substring could appear earlier in the string.

- I don't think gsub is more greedy than match - in both cases, the greediness is controlled by the regex syntax you use, not by whether you're using match or gsub. 

The string$ I'm using grabs the last instance of this pattern and I really do think that's sufficient here.