dbroada 发表于 2022-7-6 10:54:15

Find & Replace

I'm sorry to be asking this as I should be able to do it myself and indeed have routines that ALMOST do what I need, but as usual I am in a hurry.
 
Has anybody got a routine that will replace the 2nd character in a (select by mouse) string with "Z"?
 
That is I need to select the text GS-1330/1A and have it updated to GZ-1330/1A
 
-------------------------------
 
I've now read what I need to do properly and I should be asking for the 2nd letter to become a Y

ReMark 发表于 2022-7-6 11:15:42

Wouldn't you be able to do this using the normal FIND command and wildcards?

dbroada 发表于 2022-7-6 11:22:57

not easily as the first letter isn't fixed. I have done one sheet (out of many) with find A?- replace with AY- but I have a complete alphabet to go through.
 
Searching for ??- gives me ?Y-

alanjt 发表于 2022-7-6 11:33:47

(defun c:test (/ ss) (if (setq ss (ssget "_:L" '((0 . "MTEXT,TEXT"))))   ((lambda (i / ent s)      (while (setq e (ssname ss (setq i (1+ i))))      (setq s (cdr (assoc 1 (setq ent (entget e)))))      (entmod (subst (cons 1 (strcat (substr s 1 1) "Y" (substr s 3))) (cons 1 s) ent))      )    )   -1   ) ) (princ))

alanjt 发表于 2022-7-6 11:50:42

(defun c:test (/ ss replace) (if (and (setq ss (ssget "_:L" '((0 . "MTEXT,TEXT"))))          (/= "" (setq replace (getstring "\nSpecify replacement letter: ")))   )   ((lambda (i / ent s)      (while (setq e (ssname ss (setq i (1+ i))))      (setq s (cdr (assoc 1 (setq ent (entget e)))))      (entmod (subst (cons 1 (strcat (substr s 1 1) replace (substr s 3))) (cons 1 s) ent))      )    )   -1   ) ) (princ))

dbroada 发表于 2022-7-6 12:04:18

thanks Alan, I'll try it on Monday but the problem has gone away (from me). I went home early unwell yesterday and left the problem with somebody else   Should be done by Monday!
页: [1]
查看完整版本: Find & Replace