Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
soma lingam
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
soma lingam
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
% is nothing to do with that just only a one regular expression
after what ever we give the value it has to be checked
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic