This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regular Expression.  RSS feed

 
Mag Yeoh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


any one can help me on this error...i need to check String is all contain alphabet.
can i use this to check

Thanks in advance.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your regex now says: it can be a letter, either upper or lower case. Look at the quantifiers.
 
Mag Yeoh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks....

I need to use [a-zA-Z]* only can read. Another issue i hit is , if my String is 'Programing Lang' , also cannot check for all is alphabet.

How to add in checking for space in the String and concat all together like 'ProgramingLang' , this use to check for all is alphabet.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now your regex is saying: it can be 0 or more letters either upper or lowercase.
You want: it can be 0 or more, upper or lowercase letters or a space.

Hint: what do the brackets do?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!