abra-CAD-abra Posted September 28, 2015 Share Posted September 28, 2015 I have lots of text on a drawing in the following form: "B=12 37 54.1 L=........." Now, since the above string does not contain the degrees (%%d ) minutes (') and seconds (") symbols I am trying to substitute the spaces, as follows: 1st space location: "%%d" 2nd space location: """ 3rd space location: "'" I was looking at using Vl-String-Search, Vl-String-Position and Vl-String-Subst but the spaces may not always be located in the same position - Bump! As always, I appreciate any guidance. Cheers, Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 28, 2015 Share Posted September 28, 2015 Perhaps something like: (defun foo ( s l ) (if (and l (wcmatch s "* *")) (foo (vl-string-subst (car l) " " s) (cdr l)) s ) ) Or: (defun foo ( s l ) (if l (foo (vl-string-subst (car l) " " s) (cdr l)) s) ) Or: (defun foo ( s l ) (foreach x l (setq s (vl-string-subst x " " s))) ) Example: _$ (foo "B=12 37 54.1 L=........." '("%%d" "\"" "'")) "B=12%%d37\"54.1'L=........." Quote Link to comment Share on other sites More sharing options...
rlx Posted September 28, 2015 Share Posted September 28, 2015 Lot of viewers , no thank you's. Not that I think you're losing sleep about it and I centainly don't wanny get sticky , but brilliantly short and effective Lee , as always. Gr Rlx Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 28, 2015 Share Posted September 28, 2015 Thank you rlx. Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted September 28, 2015 Author Share Posted September 28, 2015 Thanks Lee, spoilt for choice! Perfect with a capital 'P'... Much appreciated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 29, 2015 Share Posted September 29, 2015 You're most welcome abra-CAD-abra 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.