How to extract a given substring based on next starting and ending values


#1

hello, I am having difficulty extracting a varible length substring from a given string. For instance I am trying to draw out all of the nicknames in a dynamo script. for example I know that the nickname looks like nickname=“List.Clean|DanEDU”, but it can be any name. So I want to use something like in excel you would use find(nickname="*") where the * would find anything in between those characters that meet the rest of the sting. But I cant seem to find a node that does that in Dynamo. please advise. thanks!


#2

Use String.SplitByRegularExpression from Clockwork package (or find or Replace)


#3

Is there a way to do this using a different starting and stopping point? Since I am trying to separate the nodes in a text file, the starting and stopping points are all the same between each node, but are different between themselves.

Also, why is this node REMOVING my regular expression from my string?


#4
  1. Split the string the lines.
  2. String.StartsWith node to find the boolean s which begin with “nickname”
  3. Parse those lists as needed to replace/edit content.
  4. String.Join node to recreate a item.
  5. Write to a new file.

#5

How do I split the string lines please?


#6

String.Split node.

String is your original text.
Separator0 is a \r\n value.


#7

I dont seem to be able to split the expression to anything.


#8

I have just build a node for this… Node is named String.Substring

The migration solution you are trying to build in this post seems to be what I have build in the other thread you have made which is essentially the same problem!


#9

A node to duplicate an existing function? Why?


#10

Wow look at you go! I guess I can just convert via your script. But just so I dont get left behind I dont know how you intend to use the Sting.Substing node. I mean it sounds great, but this is what comes to my mind: Starting index; probably easy enough if all nodes are the same up unitl “nickname”, ending length = ?? because all the names are different lengths. So how exactly do you use that?image

@JacobSmall
I dont understand your used of the string.starts with either. I was able to get what looked like more promising results with String.Contains node. What exactly do you have in mind here?


#11

@mix
start reading what I write… I have made a NEW node named “String.Substring”

…and script is a textual code mainly used is python scripting nodes, while graphs is what we build using dynamo.

You should be able to use my GRAPHS i have released at the other post where you started asking for migration om my long gone deprecated DanEDU package.


#12

Oh yeah sorry, I figured that out when I opened your other “GRAPH”. :sweat_smile: I had some trouble with it however. Please see my comments on your other post.


#13

I managed also to solve that problem… it is a matter of filtering for the nodes you use in a graph, and leave the other out…