Seperate numbers from text

thierry douez at wanadoo.fr
Wed Apr 6 04:18:44 EDT 2005


Hi,

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

try this :

  put "asdfsdfsdf765xcxccxcv123cvccv" into s
  -- erase all numbers
  put replaceText( s, "\d+",  empty ) into r1
  
  -- erase all text
  put replaceText( s, "[^\d]+",  empty ) into r2
  
  put "1st replace: " & r1 &cr& "2nd replace: " & r2

In the Doc, you can look at matchText, matchChunk, replace, replaceText,
regular expression,....

HTH,
thierry

DR> Cheers Thanx........





More information about the use-livecode mailing list