aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes java.util.regex for searching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "java.util.regex for searching" Watch "java.util.regex for searching" New topic
Author

java.util.regex for searching

Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Hi guys, my name is Jeffry. Can you help me to pattern used by the regex to do simple searching?

Assuming I have an ArrayList that contains movies title like this:
Batman
Batman Forever
Batman Returns
Batman Begins
Batman, the Dark Knight //coming soon in July 2008

when I search with the word "bat", I want the movies title above are print in the screen to prove that the pattern is right as well as I search using the word "man" (if there is a title named "Superman", it will print too).

Thanks for your help. Currently I'm developing DVD Rental application in my thesis project.


Thanks


Jeffry Kristianto Yanuar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42585
    
  65
Is there a particular reason you want to use regexps? It seems that this could be easily done using a couple of String.indexOf calls.


Ping & DNS - my free Android networking tools app
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Is there a particular reason you want to use regexps? It seems that this could be easily done using a couple of String.indexOf calls.


Nope, but if you have the solution with "a couple of String.indexOf calls" as you said, I'll take your solution. This is my own project, developed only by me and I only need simple searching like I posted before.


Thanks

Jeffry Kristianto Yanuar.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42585
    
  65
Instead of just giving out solutions, we prefer to lead people to them. You could iterate through the List, and check indexOf("bat") and indexOf("man") to each element of it. You probably want to lowercase the array elements before calling indexOf to make sure you find "Man" as well as "man".
Jeffry Kristianto Yanuar
Ranch Hand

Joined: Oct 01, 2007
Posts: 759
Ok Ulf, I'll try.


Thanks


Jeffry Kristianto Yanuar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.util.regex for searching