Solved

Searching files without file extension

Posted on 2009-05-19
3
614 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Invest in your employees with these five simple steps to improve employee engagement and retention.
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

630 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