3.5.7.32 NumExtract
Description
This function takes a mixed string "str$" and returns the count-th consecutive digit block. If count is omitted it defaults to 1 (i.e. return the first block).
Syntax
string NumExtract(string str$[, int count, int decimal])$
Parameters
str$
- is a string from which to extract number(s).
count
- Optional parameter. count is a integer specifying the nth digit block to extract. It is optional. Default is 1, which means return the first digital block in the string str$. count = 0 returns the last block.
decimal
- Optional parameter. decimal determines whether to use the decimal separator in the text string opposite to current system used. If text str$ uses comma "," as the decimal separator and the current system uses period ".", set decimal to 1 to treat comma as decimal separator. Vice versa.
Return
Returns the count-th consecutive digit block in str$.
Example
numextract("1-413-586-2013",2)$=; //should return 413 numextract("1-413-586-2013",0)$=; //should return 2013 numextract("Jan-12")=; //should return 12, "-" in a string will not be treated as minus sign NumExtract("abcd12,343")$=; //should return 12, compare with next script NumExtract("abcd12,343", 1, 1)$=; //should returns 12,343, starting from "1" and "12,343" is treated as one number "12.343"