我有以下文字:
“我哥哥喝了 7 杯咖啡,然后用 A4 纸打印了作业。然后他开车沿着 I-90 高速公路行驶。”
我只想提取文本的数字(在本例中为 7、4、90)。我怎么能用coldfusion做到这一点?
我怀疑必须使用 REMatch 函数,但我不擅长正则表达式,感谢大家的帮助。
最佳答案
只需使用重新匹配,这将返回匹配数字数组。
<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#">
关于regex - 在coldfusion中从文本中提取数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6911402/