Solved

Searching files without file extension

Posted on 2009-05-19
3
612 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
The viewer will learn common shortcuts with easy ways to remember them. The viewer will then learn where to find all of the keyboard shortcuts, how to create/change them, and how to speed up their workflow.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

756 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