I want to catch numbers which are placed in text after word "NETTO-PRICE:" (there are few spaces in between too).
Text (eventually this text has got 2 lines/rows):
PRODUCENT: AMD MODEL-LINE: ATHLON CORES: X2 MODEL: 7750 FREQ: 2.6 CORES: 6 THREADS: 2 NETTO-PRICE: 250.00 QUANTITY: 7 PRODUCENT: INTEL MODEL-LINE:i7 CORES: X4 MODEL: 720QM FREQ: 2.8 CORES: 4 THREADS: 8 NETTO-PRICE: 450.00 QUANTITY: 5
I tried this: string.match(/[0-9]/g);
but it catches all numbers in this text, when i only want those numbers after NETTO-PRICE:
This however doesn't work, cause it shows null: string.match(/NETTO-PRICE:[0-9]/g);
And if i am trying to concatenate this "arguments" in match()
method, error comes up.
[edit]
I want to get only this numbers (as price), cause later i will be calculating brutto price and difference between netto (this numbers) and calculated brutto.
[edit2]
How to change this code below to make it work for variable with whole text, not just text in quotes? Something like var s = string.split(' ');
And string contains whole text and furrther the code will be like:
var s = 'NETTO PRICE: 321.321'.split(' ');
if(s[s.indexOf('NETTO') + 1] === 'PRICE:')
console.log(s[s.indexOf('NETTO') + 2])
else
console.log('fake');