Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Searching files without file extension

Posted on 2009-05-19
3
Medium Priority
?
618 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
2 Comments
 
LVL 85

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Eseutil Hard Recovery is part of exchange tool and ensures Exchange mailbox data recovery when mailbox gets corrupt due to some problem on Exchange server.
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

824 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