No worries.
1) \b is the word boundary matcher, \s is the white space matcher. $ is the end of line matcher. | (pipe) is an or. So (\b\s|$) matches "the end of a word or the end of a line". Since \b only catches the transition from \w (word characters) to \W (non-word characters) in either direction, it's insufficient for finding a break in the command line as I'm using it. \b would match the location between "foo" and "-bar" in "foo-bar" because - is not a word character. Similarly, there's no tradition after foo in "foo" because the end is reached and there isn't another character to transition to.
2) There are: "general", "rollresult", "gmrollresult", "emote", "whisper", "desc", or "api".
Read about them all here: https://wiki.roll20.net/API:Chat
3) msg.selected is only present if there are selected things. In javascript, since all things have a "truthiness", the logic operators return the things compared, rather than a Boolean. That means an operation with || (logical or) will result in the first "truthy" argument, so it can be used to provide a default value for an expression that might otherwise be missing. So this is "use the msg.selected array if it exists, otherwise use this empty array []". This is an idiomatic way in javascript to deal with missing data. In the case that nothing is selected, this chain of operations will not be executed because the length is 0 on the array.
4) => us the "fat arrow" syntax for defining functions. This is passing a function to the .filter() operation on the array that's being worked on in that chain of commands. The .filter() on an array will return a new array containing all the elements of the source array for which the predicate function passed to it returns true. The predicate function in this case is g=>undefined !== g A function that takes g and compares it to undefined. So this line removes anything that was selected but wasn't a graphic (drawings, text, etc). That predicate function could be written more traditionally as function(g){return undefined !==g;}
Hope that helps! Ask more questions if you like!