2011-08-02 43 views
4

我有以下文字:“我的哥哥喝醉了7杯咖啡,然后打印他的家庭作业在A4纸上随后,他开车沿着I-90高速公路” 从文本中提取号码的ColdFusion

我想只提取文本的数字(在本例中为7,4,90)。我如何用coldfusion做到这一点?

我怀疑REMatch功能必须使用,但是我对正则表达式不太熟悉,我很感谢大家的帮助。

回答

11

只要使用重新匹配,这将返回匹配数字的数组。

<cfset str = "my brother drunk 7 cups of coffee and then printed his homework in A4 paper. He then drove down the I-90 highway"> 
<cfset arrSearch = rematch("[\d]+",str)> 
<cfdump var="#arrSearch#"> 
+0

感谢您的回答,它的工作原理。 – fozzer