Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to search among a list of string values, for e.g.,
[Bank A/c, Bank OD A/c, Cash in hand, Deposits, Sundry Debtors, Sundry Creditors, Miscellaneous, ...]

If I type 'Ba' in the search box, it must return me result set as:
[Bank A/c, Bank OD A/c]

or if I type 'or', it must return to me result set containing strings:
[Sundry Debtors, Sundry Creditors]

What I have tried:

1. [_typedName]+
2. _typedName+
3. _typedName*
Posted
Updated 18-Feb-16 2:43am

I would strongly recommend to go through this

The 30 Minute Regex Tutorial[^]
 
Share this answer
 
Not Regex. There have too many patterns to match. Instead, try and adapt from this example:
C#
using System;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var list = new List<string>();
		list.Add("Bank A/cat");
		list.Add("Bank OD A/c");
		list.Add("Cash in hand");
		list.Add("Deposit");
		list.Add("Sundry Debtors");
		list.Add("Sundry Creditors");

        // Your search string here
        string search="or";		
			
		foreach (string element in list)
		{
			if (element.IndexOf(search) != -1)
			{
				Console.WriteLine(element);
			}
		}
	}
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900