Searching a package

Can anybody tell which package String.RemoveAfterCharacters , String.RemoveCharacterAtIndex belong to?

String.RemoveAfterCharacters=Rhythm
The second i donā€™t knowā€¦but maybe i have my package version is to old
The zebra package has a node like that:https://dynamonodes.com/category/zebra/

Thanks for your reply.
There is one such node in Zebra package but even after I install it, the node shows ā€œUnresolvedā€

Yeah, it used to be. Until I was needing to remove all DYFs to maintain compatibility resulting in the removal of that node and others.


That being said, this python script will remove all characters after a given character if they are present :

Remove After Given Character

(paste the following into a python node)

import clr

# allows us to convert the input to a list to iterate over
def tolist(obj1):
	if hasattr(obj1,'__iter__') : return obj1
	else : return [obj1]
	
# inputs
strings = tolist(IN[0])
separator = IN[1]

# to return the new stuff
newStrings = []

# iterate through the strings
for string in strings:
	newStrings.append(string.split(separator,1)[0])

#Assign your output to the OUT variable.
OUT = newStrings

image


And this script will return the character at the given index if there is a character there. If not, it returns null.

Character at Index

(paste the following into a python node)

import clr

# allows us to convert the input to a list to iterate over
def tolist(obj1):
	if hasattr(obj1,'__iter__') : return obj1
	else : return [obj1]
	
# inputs
strings = tolist(IN[0])
index = IN[1]

# to return the new stuff
character = []

# iterate through the strings
for string in strings:
	try:
		character.append(string[index])
	except:
		character.append(None)
#Assign your output to the OUT variable.
OUT = character

image

1 Like

Thanks a lot :slightly_smiling_face:

Of course! Hope that helps out. I updated the post to have CharacterAtIndex as well. :wink:

Hello,
the CharacterAtIndex is working fine but Remove After Given Character shows this error message once Run :
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. **
Traceback (most recent call last):
** File ā€œā€, line 17, in

AttributeError: ā€˜listā€™ object has no attribute 'splitā€™

Capture3

What does your input look like? Is it a list of lists? Because you might need to flatten it first.

This node saved my day !!! impossible to range my view and with that is cool ā€¦ and my first test to use a code python and itā€™s run , happy, thanks john pierson !!!