How can we validate a string consist any single alphabets or not in scala?

My application takes in a string like this:

  • k0qVsfpz7_cG9n75OjZCCA
  • P700058213111115432196
  • 1700058213111115432196

I need to validate in a Scala script that the string consists of any single alphabet or not.

Answers


Consider exists method over a given string, which maps each character onto a predicate provided. For instance, Char.isLetter proves true only if a given character is an alphabetical value (a letter). Hence

"P700058213111115432196".exists(_.isLetter)
Boolean = true

and

"700058213111115432196".exists(_.isLetter)
Boolean = false

Similarly with forall we can verify that each and every character in a string holds a predicate, for instance

"P700058213111115432196".forall(_.isDigit)
Boolean = false

and

"700058213111115432196".forall(_.isDigit)
Boolean = true

To remark that both exists and forall iterate over a collection. Here we iterate over a Scala string which is treated as a sequence of Char.


Need Your Help

stack data between languages

c++ assembly types stack

Lets say for example, I push a large amount of data onto the stack using some assembly code. My question is, is it possible to manipulate this data in a language such as c++ by passing the address ...

Editing the WSDL generated by a web service

c# xml web-services wsdl editing

I have a basic web service that parses XML sent from a client. The web service works fine but I was asked to remove elements from the WSDL file generated by the web service. Is it even possible to do

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.