Javascript regex pattern for specific case

I need to split it to get only 1 and 6 and I only want whole number I
want to ignore the floating numbers

You can use String.prototype.split() with RegExp /\D|\d+\.\d+/ to split characters that are not digits, or digits followed by . character followed by digits to handle for example 2.456, Array.prototype.filter() with parameter Boolean to remove empty strings from result


Browse More Popular Posts

Leave a Comment