adding regex with global flag to "replace" function that prepares result item class

if there are three classes e.g. "a b c" a "replace" function will output "a.b c". I do not use global flag as a parameter because it does not work on webkit browsers.