File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Pattern Matching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Pattern Matching" Watch "Pattern Matching" New topic
Author

Pattern Matching

Santana Iyer
Ranch Hand

Joined: Jun 13, 2005
Posts: 335
Hi,

I am doing small project like window search facility in java,
so I wanted to know when I give input in box (*.ext) or (filename*.ext)
is there any API available to do matching with existing file.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
You can check out java.util.regex.Pattern & java.util.regex.Matcher classes to get this functionality. Here is a link to the Sun tutorial on regular expressions.


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Santana Iyer
Ranch Hand

Joined: Jun 13, 2005
Posts: 335
Thanks, actually I was reading about it
but still I am not able to find right solution
if someone enters abc*.txt now what kind of regex to create
abc[*]* does not work nor abc[.]* works....
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Try this
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18117
    
  39

Originally posted by Santana Iyer:
Thanks, actually I was reading about it
but still I am not able to find right solution
if someone enters abc*.txt now what kind of regex to create
abc
  • * does not work nor abc[.]* works....


  • I agree that you should take the time to learn regex, it will come in really handy during your career. It is not simple to learn, but is a fantatic tool to use once you get comfortable with it....


    Anyway...

    To match "abc*.txt", use "abc.*\\.txt"

    Henry


    Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Pattern Matching
     
    Similar Threads
    package,classpath and servlet
    mime type in web.xml
    Configuring JDK for Servlets
    Connecting to CVS server
    jQuery and Ext