File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Regex pattern - unprintable characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regex pattern - unprintable characters" Watch "Regex pattern - unprintable characters" New topic

Regex pattern - unprintable characters

Pavan Kumar
Ranch Hand

Joined: Jan 23, 2004
Posts: 78
I'm unable to figure out a pattern in regex for the following problem, I'd very much appreciate your inputs in this regard,

I must validate a String, the validation rules are.
The String must not start with an underscore(-), a space or an unprintable character.
The string must not contain any empty spaces or unprintable characters.

Except for unprintable characters my pattern looks OK, here's what I have

Could you please suggest me how to enhance my pattern in order to check for any unprintable characters in the string.


formerly known as Cnu
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Check this out in the Pattern API :

POSIX character classes (US-ASCII only)
\p{Print} A printable character: [\p{Graph}]
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
I agree. Here's the link:
subject: Regex pattern - unprintable characters
It's not a secret anymore!