wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Regular expression to find whether line DOES NOT end with a specific pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Regular expression to find whether line DOES NOT end with a specific pattern" Watch "Regular expression to find whether line DOES NOT end with a specific pattern" New topic
Author

Regular expression to find whether line DOES NOT end with a specific pattern

Kingsly Theodar
Greenhorn

Joined: Feb 21, 2004
Posts: 19
Hi,

I have list of directories and java files.

/usr/com

/usr/com/file1.java

/usr/com/file2.java

/usr/com/regexdir1

/usr/com/regexdir2

/usr/com/regexdir1/file3.java

/usr/com/regexdir2/file4.java

For selecting lines ending with ".java", I will use regular expression "*.java"

But for selecting list of directories, I am aware that I should select all the lines that does not match the pattern "*.java"

How will I express this in regular expression?

Any help on this is greatly appreciated. Please help.



Thanks,

T.Kingsly
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If it fails that regular expression than you should know it is a directory.

You could easily just do

Eric
Kingsly Theodar
Greenhorn

Joined: Feb 21, 2004
Posts: 19
Hi Eric Pascarello,
That looks great.
But the tool I am using accepts only Regular expression.
Any idea of using regular expression for the same?

Thanks,
T.Kingsly
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Something like this?

.*[^\.java]

Eric
Kingsly Theodar
Greenhorn

Joined: Feb 21, 2004
Posts: 19
Bingo. That is the one.

Thanks for sharing it Eric



Thanks,
T.Kingsly
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular expression to find whether line DOES NOT end with a specific pattern
 
Similar Threads
Read from file.
How can I add error handling facilities to this code?
Regular Expression requred to get Java class names from text file
criteria string
Regular Expression