Solved

regular expression with chinese characters

Posted on 2013-06-21
5
570 Views
Last Modified: 2013-07-22
i want to come up with regular expression that excludes these characters:

`~!@#$%^&*()_+-=\][|}{‘;”:/.,?><

but whatever i come up with also excludes foreign language characters such as chinese or russian:

¿¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿¿

can someone tell me if regular expression is the best way to handle this type of situations?  thanks.
0
Comment
Question by:mmingfeilam
  • 4
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39267117
Chinese characters not a problem - see example below

Russian won't be a problem either
chin.png
0
 

Author Comment

by:mmingfeilam
ID: 39267342
Can you do an example using reg ex?  Not sure if string replacement is the same as regular expression.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39267350
Yes, it is the same essentially. Is what you're after to test if the string includes any characters that should be excluded and to declare it invalid otherwise?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 39267376
boolean valid = s.matches(.*"[~!@#$%^&*()_+-=\\]\\[|}{‘;”:/.,?><].*)";

Open in new window

would do it if that IS the case
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39344147
:)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question