Notifications
Clear all
[Closed] Get the suffix of object name?
Aug 15, 2015 12:31 am
If I have a selected object and I want to extract just the last part from it name that’s after the _ (underscore).
Example:
--$Teapot001_va the object thats curently selected
print $.name -- want _va in this case to print
But I want to print only the last part that’s after the underscore, and the part after the last underscore might very in length and what text it is, also the object name might contain multiple underscores.
PS: Whats the correct way / recommended way of making new threads, If I recently made another thread, but I have a new different question that’s not really related to the other threads question, is it ok to make a new thread for the new question?
Thanks.
3 Replies
Aug 15, 2015 12:31 am
Using [b][i]filterString
[/i][/b]
(
selObjName = selection[1].name -- "Teapot001_va"
str = filterString selObjName "_" --> #("Teapot001", "va")
suffix = str[str.count]
)
1 Reply
Aug 15, 2015 12:31 am
you can also use regex…
((dotnetclass "System.Text.RegularExpressions.Regex").match "Teapot001_va" "_\w.$").value
"_va"