0

I have a string. For now lets go with $string="mFN6jTPx?!". I would like to be able to count how many capital letters there are. I have tried using ($string -cmatch '[A-Z]').length but that only comes back as 1 given it brings back true or false value. I have also tried using ($string -creplace '^[A-Z]') but it just brings back mFN6jTPx?! so doing length check will not get me the correct number. Any ideas?

1 Answer 1

1

Not really SharePoint related, but does this work?

($string.ToCharArray() |Where{$_ -cmatch '[A-Z]'}).count

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.