Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Regular Expression

 
kayanaat sidiqui
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my code i have a string.
Now in this string i need to print a warning message, if contains
any character other than (A-Z,a-z,0-9,_)

I tried to do with contains([A-Za-z0-9_])and pattern().
But could not get through.

Where am i doing mistake. Can you please point it out..

Tahnks,
Kaya.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the API of java.util.regex.Pattern. It clearly specifies how to create an "Any character except" character class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic