Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find count of digits in string variable using scala?

Tags:

scala

I have a string variable like below

val str="raid11112233rdfg"

If i wanted to find the count of digits in string variable using scala how to solve this.Ideally it should give output as count of 8.

like image 520
user2185752 Avatar asked Oct 20 '25 04:10

user2185752


1 Answers

such as

str.count(_.isDigit)

might just work.

like image 132
Steve Massey Avatar answered Oct 21 '25 17:10

Steve Massey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!