Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting numbers from text in coldfusion

I have the following text: "my brother drunk 7 cups of coffee and then printed his homework in A4 paper. He then drove down the I-90 highway."

I want to extract only the numbers of the text (in this example 7,4,90). How can I do this with coldfusion?

I suspect the REMatch function must be used but I am not good with regular expressions, I appreciate everyone's help.

like image 911
fozzer Avatar asked Dec 12 '22 10:12

fozzer


1 Answers

Just use rematch and this will return array of match numbers.

<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#">
like image 157
Pritesh Patel Avatar answered Dec 14 '22 23:12

Pritesh Patel