A great deal of regex engines use a "multi-line" mode in order to search several lines in a file independently.
Therefore when using $
, these engines will match all lines' endings. However, engines that do not use this kind of multi-line mode will only match the last position of the string provided for the search.