ReplaceAll.bmx 553 B

12345678910111213141516171819202122232425262728293031
  1. ' Replaces all float/numeric values with '!GONE!'
  2. SuperStrict
  3. Framework Text.RegEx
  4. Import BRL.StandardIO
  5. Local change:String = "floats are 4.533, -10.232, 1446.2003 and even 100~n" + ..
  6. "If it wasn't enough 5 out of 10 applications said their users preferred them. That's 0.50 !~n"
  7. Local regex:TRegEx = TRegEx.Create("[-+]?[0-9]*\.?[0-9]+")
  8. Try
  9. Local s:String = regex.ReplaceAll(change, "!GONE!")
  10. Print "before = " + change
  11. Print "after = " + s
  12. Catch e:TRegExException
  13. Print "Error : " + e.toString()
  14. End
  15. End Try
  16. Print "Done."