csbukhari csbukhari - 2 months ago 5
Node.js Question

How to count curly brackets in nodejs

I'm trying to find a way to count how many curly brackets in any string.

For example:

Dear {0}, Your one time password is {1} Thanks

I found https://www.npmjs.com/package/matchstick but it does not work as I need.



var count = ("Dear {0}, Your one time password is {1} Thanks".match(/{|}/g) || []).length;

Hope it helps.