Jump to content

Complex String Handling


abra-CAD-abra

Recommended Posts

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! :unsure:

 

As always, I appreciate any guidance.

 

Cheers,

Link to comment
Share on other sites

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=........."

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...