Grasshopper

algorithmic modeling for Rhino

hey,

 

I do have a string (something like M2363_7034_574523) and I want to replace always the 8th position. In this case 0 has to become 7.

 

Thanks for help

 

DeDackel

Views: 520

Replies to This Discussion

Hello,

 

Although I'm told 'Mid' is a bit anachronistic, in VB you can use:

Dim s As String = "test string"

Mid(s, 7, 1) = "p"

 

In C# you can use: 

string s = "test string";

var sb = new StringBuilder(s); 

sb[7] = 'p';

s = sb.ToString();

 

In python, there are a bunch of different ways to do this. Here's one way using string slices

 

s = "M2363_7034_574523"

s = s[:6] + "0" + s[7:]

 

 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service