Solved

Searching files without file extension

Posted on 2009-05-19
3
608 Views
Last Modified: 2013-12-17
Hi Guys,

I want to search for all files without file extensions using regular expression.  For examples, I have these files:

file1.xml
file2.dos
file3
file4.pcc
file5


Result is

file3
file5




Thank you in advance
0
Comment
Question by:xanbi
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 24428982
^[^.]*$
0
 
LVL 2

Assisted Solution

by:see4me2002
see4me2002 earned 125 total points
ID: 24460390
Hope this helps. below gives the extension separately
***********************

import java.util.regex.*;

public class Main {
    public static void main(String[] args) {
        /*
        Regex: (?<=\\.).*$
        1.)     (?<=\\.)    means       lookbehind excluding "." and add
        2.)     .*          means       every character until
        3.)     $           meabs       end of string
        */
       
        String
                regex = "(?<=\\.).*$",
                input = "C:\\dir\\filename.txt";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(input);
        String output = "no match";
        if (matcher.find()){
            output = matcher.group();
        }
        System.out.println("\t Output: " + output);
    }
}

******************

Output : txt

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifiā€¦
Viewers will learn how to use the Hootsuite Dashboard.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now