Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Searching files without file extension

Posted on 2009-05-19
3
Medium Priority
?
616 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 500 total points
ID: 24428982
^[^.]*$
0
 
LVL 2

Assisted Solution

by:see4me2002
see4me2002 earned 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
Viewers will learn how to use the Hootsuite Dashboard.

670 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