Jump to content
Developer Wiki and Function Reference Links ×

Issue with repeating substrings in "Strip" Node


Recommended Posts

hey there,


can someone explain how I could use the Strip Node whilst using repeating "sub-parts" of the"substring

string Input is:

TestStringStripFriend-From Test ("From" should stay)


Strip Operator is:


result is:

om Test ("From" should stay)



result should be:
From Test ("From" should stay)



Anyone? Cheers!

Link to comment
  • Marionette Maven


It appears this is happening because it's counting the "Fr" in From and not just Friend, if you change the capitalization to lowercase for "from" then it works.

I'm looking into this, the strip function is built-in for Python, so we don't do the handling for it within this node, but maybe there's something we can do to add our own handling.



Here's a post about how the Python "strip" function works:
I'll think about how we can get around this limitation.

In the meantime, I would suggest using the Replace String node with an empty string as the input for sNew.

  • Like 1
Link to comment



you may want to use.


These functions seem to do what you are searching for.


A Marionette node with the functions above could look like this:

class Params(metaclass = Marionette.OrderedClass):
	this = Marionette.Node( "remove suffix prefix" )
	this.SetDescription('Removes the suffix or the prefix from the full string.')
	#Input Ports
	s = Marionette.PortIn( '', 's' )
	s.SetDescription('The full string.')
	s2 = Marionette.PortIn( '', 'sSub')
	s2.SetDescription('The substring.')
	#OIP Controls
	pos = ['left', 'right', 'both']
	position = Marionette.OIPControl( 'Position', Marionette.WidgetType.RadioButton, 0, pos)
	position.SetDescription('an OIP control representing the position options for where the string gets stripped.')
	#Output Ports
	outList = Marionette.PortOut('sNew')
	outList.SetDescription('The stripped string.')
def RunNode(self):
	s = self.Params.s.value
	s2 = self.Params.s2.value
	pos = self.Params.pos
	position = self.Params.position.value
	if pos[position] == 'left':
		sNew = s.removeprefix(s2)
	elif pos[position] == 'right':
		sNew = s.removesuffix(s2)
	elif pos[position] == 'both':
		sNew = s.removeprefix(s2).removesuffix(s2)
	self.Params.outList.value = sNew

You can create the node by replacing the code of any Marionette node with the code above.






  • Love 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...