You're in double luck.... I created a a similar routine in the same thread as pkenewell, an alternative method. Likewise, the same text length limit applies - can adjust these if that becomes an issue (for most things, 256 characters is usually enough except a notes block of text)
(defun c:TxtRemCR ( / MySS SSCountMyEnt MyEntGet Mytext TextList OrderList NewText n acount) ; txt remove carriage returns
;;Sub Functions:
;;Starting with LM: Refer to Lee Macs website
(defun LM:str->lst ( str del / pos )
(if (setq pos (vl-string-search del str))
(cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
(list str)
)
)
(defun LM:lst->str ( lst del )
(if (cdr lst)
(strcat (car lst) del (LM:lst->str (cdr lst) del))
(car lst)
)
)
(princ "\nSelect MText") ;; Note in command line "Select text"
(setq MySS (ssget '((0 . "MTEXT")))) ;; Select objects with a selection set, filtered to 'MTEXT' entity type
(setq SSCount 0) ;; Just a counter set to 0
(while (< SSCount (sslength MySS)) ;; loop through length or selection set using SSCount
(setq MyEnt (ssname MySS SSCount)) ;; get the nth item in the selection set entity name
(setq MyEntGet (entget MyEnt)) ;; get the entity definition from the above
(setq MyText (cdr (assoc 1 MyEntGet))) ;; get the text from the entity (first 256 characters)
(setq TextList (LM:str->lst MyText "\n")) ;; Convert the text string to a list, deliminator \n (new line)
(setq MyEntGet (subst (cons 1 (LM:lst->str TextList " ")) (assoc 1 MyEntGet) MyEntGet))
(entmod MyEntGet) ;; Modify the text
(setq SSCount (+ SSCount 1))
) ; end while
); end function