*
The moose likes Java in General and the fly likes How can we search a name with a regex like Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How can we search a name with a regex like "%" in a list of values" Watch "How can we search a name with a regex like "%" in a list of values" New topic
Author

How can we search a name with a regex like "%" in a list of values

soma lingam
Greenhorn

Joined: Apr 26, 2007
Posts: 19
Hi,

I have a severe, error while implementing with regex "%" followed by a name to search like "%srin" for example:
Code: -
List l = new ArrayList();
l.add("srinivas");
l.add("Sridharsrinivas");
l.add("manojsrinivas");
l.add("abc");


How can i able to implement by searching like %srin should give me the whole contents that are available.
Help me please,
I am awaiting for your replies guys,

Thanks,
Ravinder Rana
Greenhorn

Joined: Dec 07, 2006
Posts: 19
Do you mean that it should return all the strings which contain "srin" string in it? If yes, following is the code which does the same:

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
What is the '%' supposed to do - does it just mean there can be any prefix to the 'srin'? If so, no regexp is necessary - plain old String.indexOf should do nicely.


Ping & DNS - my free Android networking tools app
soma lingam
Greenhorn

Joined: Apr 26, 2007
Posts: 19
% is nothing to do with that just only a one regular expression
after what ever we give the value it has to be checked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can we search a name with a regex like "%" in a list of values
 
Similar Threads
No matches method in String class in Blackberry?
Find some Thread
Invoking Applet methods from Javascript for Netscape 6
Mixing generic and non generic legacy code issue
How to Group a Collection of Pojo's based on some pojo property?