aspose file tools
The moose likes Linux / UNIX and the fly likes named character classes in grep Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "named character classes in grep" Watch "named character classes in grep" New topic
Author

named character classes in grep

Minal Silimkar-Urankar
Ranch Hand

Joined: Nov 25, 2007
Posts: 136
I want to know how to use named charactes classes with grep command?


Minal Silimkar
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16540
    
  25

Character-class pattern for USA format date string (MM/DD/YYYY):

[:digit:][:digit:]/[:digit][:digit:]/[:digit:]{4}

Which is equivalent to

\d\d/\d\d/\d{4}

Or \d{2}/\d{2}\/d{4}

Except that character classes may be more locale-sensitive, if I understood them correctly.

Another benefit of the named classes is that backslashes can bite.
[ April 18, 2008: Message edited by: Tim Holloway ]

Customer surveys are for companies who didn't pay proper attention to begin with.
Minal Silimkar-Urankar
Ranch Hand

Joined: Nov 25, 2007
Posts: 136
How can I use the named character constants with grep command?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: named character classes in grep