I want to get how many time a regex matched in given string in JavaScript.
For example:
var string = "AABBCCaabbcc123!@#"
I want to get:
- How many upper case in string: 6,
- How many lower case in string: 6,
- How many numbers in string: 3,
- How many special characters in stirng: 3
Is there built-in js functions or simple way to implement this logic?
Thank you very much.
2
Answers
You can try the following way:
You can have this in more shorter way.Just keep the pattern correct