This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
Ranch Hand

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


Minal Silimkar
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

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
Ranch Hand

Joined: Nov 25, 2007
Posts: 133
How can I use the named character constants with grep command?
 
 
subject: named character classes in grep
 
Similar Threads
struts2: Generating list of localisation keys?
File find utility?
Maintaining File Size while writing
Command to add lines to multiple files
Search tool to search all class files