Houdini Python Node - Snippets

String

Regex

Replace

import re

REGEX_TRAILING_DIGITS = re.compile(r'^([a-zA-Z_]*?)[0-9]*$')

node = hou.pwd()
geo = node.geometry()

for prim in geo.prims():

    mat_name = prim.attribValue('shop_materialpath')
    m = REGEX_TRAILING_DIGITS.match(mat_name)
    if m:
        capt_grp = m.groups()[0]
        prim.setAttribValue('shop_materialpath', capt_grp)