Jump to content
jda823

Extracting a substring of text

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.

Share this post


Link to post
Share on other sites
[B]Welcome to CADTutor! :P

substr [/B]is the function you should read about :)

Also, take a look into [B]vl-string-search[/B] or [B]vl-string-position[/B]

Lee

[B]EDIT:[/B]

[B][URL="http://lee-mac.com/functioninfo.html"]This[/URL][/B] will help you get help on the functions

Also, I recommend read [B][URL="http://lee-mac.com/introtovlide.html"]this[/URL][/B] if you aren't already using the VLIDE to write LISP :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×