To get rid of the last comma, use this on the entire text, not line-by-line:
The regex is:
,\s*$
Without the (?m) option, "$" refers to the end of the entire string.
So this is basically searching for the last comma, optionally followed by whitespace (specifically in this case, a trailing linefeed).
But I think you can do it easier than that. You could probably do this in one regex expression, but I can't quite figure out how to add the first and last quote, so this will have to do:
If you're referring to regular expressions, it takes forever to learn them. But if you use them regularly (pun intended), you can eventually get there. My favorite website for testing them out is regex101.com, and I use it all the time to build regular expressions.