Is this Rhino 7 or Rhino 8? Windows or Mac? In Rhino or in Grasshopper.
This works in Rhino 8 CPython 3:
#! python3
import rhinoscriptsyntax as rs
import scriptcontext as sc
import math
import System
import System.Collections.Generic
import Rhino
import re
def check_len(x):
match = re.search(r'(\d+)(\w+)', x)
return int(match[1])==len(match[2])
print(check_len('5hello'))
print(check_len('4rabbits'))
And this works in Rhino 7 and 8 IronPython 2:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import math
import System
import System.Collections.Generic
import Rhino
import re
def get_num(raw_str):
number = re.search(r'\d+',raw_str)
return number.group(0)
print(get_num('5hello'))
print(get_num('10HelloWorld'))
print(get_num('16HelloWorldPython'))