EDIT: This question is DIFFERENT. The regex works fine that everyone sent me. The problem is that the $
sign DOESN'T WORK on my string, but it works on others. I can't figure out why and I posted my function below.
I need to find a number at the end of a string, it will be like thisL
My Goal Amount: $25.00/$100.00.
I've tried
var matches = fileDataResult.match(/\d+$/);
but it returns null, I tried it without the $ and it returns the 25, without the .00.
How can I get a variable as a number for the first ones (25.00, with the decimals) and a different variable for the 100.00, with the decimals as well. I need the variables seperate so I can work on them, but I think regex is broken because it won't even work with the $ sign... anyone have suggestion? This is in javascript.
edit: here is my function, it reads a .txt file and gets the string. I can console.log the string just fine and it work, but it won't work when I use $ in regex!
function fileReaderFunc(file) {
const fileReader = new FileReader();
fileReader.onload = function() {
let fileDataResult = '';
const fileData = fileReader.result;
fileDataResult = fileData.toString();
console.log(fileDataResult);
let str = fileDataResult;
let reg = /\d+(\.\d+)?$/g;
console.log(str.match(reg));
};
fileReader.readAsText(file);
}