Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
findrx
#1
Me again

Would that be the correct way to extract the Price ?

PrCalc
Code:
Copy      Help
str ChargeA

ChargeA = "(Charge A | 937,000.00)"

if(findrx(ChargeA "\d+\D\d+\D\d+" 0 2 _s)>=0) out _s
#2
Yes, if price always be with ",".

This is more universal:
Macro Macro1473
Code:
Copy      Help
str ChargeA

ChargeA = "(Charge A | 937,000.00)"
;ChargeA = "(Charge A | 93.00)"

if(findrx(ChargeA "(\d+,)*\d+\.\d+" 0 2 _s)>=0) out _s
#3
yes as usual they have "," but its perfect that it works with each amount now

thank you very much

best regards
#4
that was faster then i was able to post a thank you Big Grin

so thanks again
#5
Gintaras Wrote:Yes, if price always be with ",".

This is more universal:
Macro Macro1473
Code:
Copy      Help
str ChargeA

ChargeA = "(Charge A | 937,000.00)"
;ChargeA = "(Charge A | 93.00)"

if(findrx(ChargeA "(\d+,)*\d+\.\d+" 0 2 _s)>=0) out _s


would it be possible to remove all exsisting "," and the ".00" in the same line ? in the code above it would out 937000

i think it needs another replacerx line and thats no problem so far but i cant get the removing of ".00" to work so my best result is 937000.00

thank you
#6
Probably impossible.

Macro Macro1478
Code:
Copy      Help
_s.findreplace(",")
if(_s.end(".00")) _s.fix(_s.len-3)
out _s
#7
oh wow i didnt know of _s.end

i searched in the help just now and still cant find anything about it !? or am i blind?

thanks a lot for all ur help

best regards
#8
Ok that works great but i ran into the next problem

Its not always ".00" at the end as it can be ".11" or something else too

I have noticed that i have to learn about Regular expressions coz i hate asking u about things that probably well explained in the help

Sorry
#9
_s=val(_s)

If need to round up if > .5, use this instead:

_s=Round(val(_s 2))
#10
Ok i did it like that now and it works


Macro
Code:
Copy      Help
str ChargeA

ChargeA = "(Charge A | 937,001.00)"
;ChargeA = "(Charge A | 93.00)"

if(findrx(ChargeA "(\d+,)*\d+\.\d+" 0 2 _s)>=0) _s.findreplace(",")
,if(findcr(_s ".")) _s.fix(_s.len-3)
,out _s
#11
ops we wrote the post at the same time

ill try ur way now

thx
#12
Thank you very much it works perfect with _s=val(_s)

have a nice weekend


Forum Jump:


Users browsing this thread: 1 Guest(s)