Grasshopper

algorithmic modeling for Rhino

Remove N characters form beginning or end of a string

Hi again y'all,

It there a way of removing a number of characters from the end of a string? I have comma delimited point values in the format of "x,y,z," so I need to remove the comma from the end to make it "x,y,z" .

Bests,

Dan

Views: 4392

Replies to This Discussion

there is a component for spliting a string into individual charaters. then you could shift list -1 andstring join back together again. if you need i can post a demo later

--

David Rutten

david@mcneel.com

Poprad, Slovakia

thanks david, never thought about using the index cull like that

using an f1 component, you could use the formula

Left(x,5)

x being your list of values in x,y,z, format.

ideally it should include the string length function -1.

cannot remember if is left(x,length(x)-1) or left(x,len(x)-1)

I do like the cull index example!

Just want to say, loving the level of response on this forum. I hope to contribute something back one day!

I've tried both methods, the cull method seems faster computationally, which may be handy to know!

Thanks!

Attachments:

Note that the first time a component runs it will take a long time to complete because it must be compiled first. Try hitting F5 and then look at the real performance.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I refreshed several times, on average the function method was slower.

Not much of a big deal unless you had several several tens of thousands of points though really.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service