Seperate numbers from text

Ken Ray kray at sonsothunder.com
Tue Apr 5 22:51:09 CDT 2005


On 4/5/05 9:55 PM, "Dwayne Rothe" <drothe at optusnet.com.au> wrote:

> Is there a way to seperate numbers from text in a string?
> e.g "string69" to return 69 or "string69also" to return 69
> 
> Is it possible to filter somehow?

Well, if you only have one number in the string (i.e. not something like
"one45two50three60"), you can use this:

function GetNum pWhat
  local tNum
  get matchText(pWhat,"([0-9]+)",tNum)
  return tNum
end GetNum

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list