Jump to content

Extracting a substring of text


jda823

Recommended Posts

I am looking for a way to extract a substring of text in string of attributed text to be used as a variable so that it can be later reinserted into different parts of the drawing or used to create new layers.

 

Basically, I have a part description followed by a part number in parentheses. The part number is generally an 8 digit number, but sometimes has a -1 or -2 at the end. I have gotten as far as extracting the values of the attributed text to variables, but am not sure the best way to search for a specific part of them.

 

What is the best way to go about this? Would I want to search for the location of the first open parentheses and then the location of the close parentheses in the string and extract the text in between? Is there a better way?

 

I am somewhat new to Autolisp and most VBA stuff is over my head at this point.

Link to comment
Share on other sites

Welcome to CADTutor! :P

 

substr is the function you should read about :)

 

Also, take a look into vl-string-search or vl-string-position

 

Lee

 

EDIT:

 

This will help you get help on the functions

 

Also, I recommend read this if you aren't already using the VLIDE to write LISP :)

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