• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find and remove Non Ascii charactes from user input using java?  RSS feed

 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to find and remove Non Ascii charactes from user input using java.

Is the regexp solve?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raghu Sha wrote:How to find and remove Non Ascii charactes from user input using java.

Is the regexp solve?


Yes - regex is ideal and very very simple. Presumably you only want to keep the printable characters in the range 'space' to 'tilde' ; is that right?
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

Added "[^\000-\177]". Still some non-ascii are found.

Could you please provide the pattern match values?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't say how you are using that regex and it does not look at all right however you might be using it. You need to spend some time with http://www.regular-expressions.info/tutorial.html and http://docs.oracle.com/javase/tutorial/essential/regex/ .
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not much good at regex, but let me point out that "\p{IsBasic_Latin}" -- I'm not sure of how or whether to capitalize that -- should match any character in the Basic Latin code block, which corresponds exactly to ASCII.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!