I found an answer in this question that is almost perfect but I need a slight tweak. I've read the basics of regex and I'm using https://regex101.com/ but I can't figure it out.
Using "string".replace(/\d+$/, '') I can remove any numbers from the end of the string. However I also need to remove any numbers that have a format with a decimal like #.# or ##.# as well as whole numbers, but only when they appear at the end of the string. From regex101 I have found that the $ is for the end of the string.
I can use .replace(/\d+([.]\d+)?/g) to remove numbers and floats but it removes them from the entire string, not just when they appear at the end, and I can't work out where to put the $ as I don't really understand regex yet and can't get it to work.
It seems such a small and stupid problem but I'd appreciate the help.
Thanks