Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advanced findreplace function
#4
Macro Macro965
Code:
Copy      Help
str s="{37.5K 134K 21.37K 2.351K 0.542K 0.017K     25 1,300 2,500K}"
REPLACERX r.frepl=&sub.Callback_str_replacerx
s.replacerx("\b\d+(?:,\d+)*(?:\.\d+)?K?\b" r)
out s ;;{37500 134000 21370 2351 542 17     25 1300 2500000}


#sub Callback_str_replacerx
function# REPLACERXCB&x

x.match.findreplace(",")
double d=val(x.match 2)
if(x.match.end("K")) d*1000
x.match=d


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)