Made so that when the string has simple quotes (') they are escaped; also, if the selection ends with a semi collon (;) this char is striped out.