aspose file tools*
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
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: 41499
    
  53
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