How remove letters from end of a string ?

   10339   4   2
User Avatar
Member
407 posts
Joined: Aug. 2015
Offline
Hi;

Using VEX codes, how could I remove some letters from end of a string ?

Thanks.
Masoud Saadatmand (MSDVFX)
User Avatar
Member
52 posts
Joined: June 2016
Offline
It's a bit tricky, I don't know if there's another way or if it's working for all cases, but the idea is here : transform your name to a string array, remove the values your don't need, and write it back to a string.

Attachments:
cc_CropNameFromEnd.hip (76.0 KB)

User Avatar
Member
918 posts
Joined: March 2014
Offline
Hi,

please have a look at the string manipulation functions in the docs. In your case http://www.sidefx.com/docs/houdini/vex/functions/rstrip.html [www.sidefx.com]
Note the related functions at the bottom of that page.

Edit:

Here's some further info: http://www.sidefx.com/docs/houdini/vex/strings.html [www.sidefx.com]

string a_string = "hello world!";
string thirdbyte = a_string[:-3];

result: hello wor

Hope this helps
Andy
Edited by Andy_23 - April 2, 2018 07:50:38
User Avatar
Member
385 posts
Joined: July 2018
Offline
Andy_23
string thirdbyte = a_string;

Where can i find these expressions in the documentation?
User Avatar
Member
861 posts
Joined: Oct. 2008
Offline
Use functions that start with re_ . They take regex expressions and you should be able to do very complex replacements. Do you have an example string?
--
Jobless
  • Quick Links