var num="55+60"
num.match(/[\d\.]+/g)
I understood, it's finding the digits globally, but i couldn't understand the '[]','+' and '.' parts.
var num="55+60"
num.match(/[\d\.]+/g)
I understood, it's finding the digits globally, but i couldn't understand the '[]','+' and '.' parts.
\d
matches any digit from 0 to 9. \.
matches a point i.e. period. []
lets you define a set of characters to match. []+
means match 1 or more of the characters in the square brackets.
[\d\.]+
will match numbers such as "45" or "45.123" but also "45.123.456" and "45...123." which may or may not be intended to be matched.
This means any digit or a dot between []. and when you use it with + this means any digits or dot that repeated more than once.
this is a regex playground. You can learn more in this site