span8
span4
导入fme导入fmeobjects导入re def FeatureProcessor(feature): m = re.search(r' bredd \s*(\d+ .?setAttribute(字符串的子串,m.group (1))编辑不是很好。不能显示正则表达式中点之前的反斜杠。请在点之前插入反斜杠!
测试用例 | 铌。特点 | 运行1 | 运行2 | 运行3 | 平均 |
PythonCaller + string.find | 1 000 000 | 20.5 | 20.3 | 20.1 | 20.3 |
PythonCaller + string.split | 1 000 000 | 20.5 | 20.4 | 20.9 | 20.6 |
PythonCaller +正则表达式 | 1 000 000 | 23.3 | 21.8 | 23.6 | 22.9 |
StringSearcher | 1 000 000 | 32.7 | 32.0 | 32.4 | 32.4 |
尼斯分析,非常有帮助。我会怀疑StringSearcher会更快启动FME 2016年,作为the've替换Tcl的正则表达式引擎的东西(希望)更有效。正如你所看到的,目前StringSearcher要求进入各功能Tcl的引擎,导致相当多的开销。
出于性能方面的考虑,你也可以使用一个预编译的正则表达式,它刮胡子了几秒钟:
precomp_regex = re.compile(r'Bredd \ S *(\ d + \\?\ d *)\ S *米。? ')DEF FeatureProcessor(功能):M = precomp_regex.search(feature.getAttribute(' 文本“)) if m: feature.setAttribute('substr', m.group(1))
大卫
特性。setAttribute('substr', feature.getAttribute('text').split('Bredd')[1].split('m') [0].strip())一步一步来:
获得text属性att = feature. getattribute ('text') #Right part of Bredd Right = att.split('Bredd')[1] #Left part of m Left = Right .split('m')[0] #Trim extra spaces substr = Left .strip()setAttribute(字符串的子串的子串)
©2019安全亚搏在线软件公司法律