* Anoop wrote, On 27-7-2006 0:09:
If the search text is being entered in a Textbox or any other visual
component then one Solution could be to capture the Keypress event and then
ignore the space and comma and just store the actual text in a variable but
display everything.
I am new to the .net but there should a method to find a particular
character in a string and retrieve the rest of the string.
"Sa¹o Zagoranski" <sa**@skz.siwrote in message
news:HW********************@news.siol.net...
>>You would have to explain the business rules of your "search filter."
As I wrote:
Something like this:
> If a user enter "song, song" the filter has to find:
song song
song song
song,song
as well as:
> blasong, songbla
blasong, songbla
but not this:
song sometext song
The filter has to ignore spaces and commas between the words entered.
You'll have to generate a regex on the fly to handle this:
string input = "bla bla song song...... bla bla";
// read the input from the user
string inputRegex = "song, song";
// replace space with comma, because Regex.Escape will escape whitespace
inputRegex = inputRegex.Replace(' ', ',');
// Escape the string to prevent regex injection
inputRegex = Regex.Escape(inputRegex);
// build the actual search expression
string searchExpression = Regex.Replace(inputRegex, "[, ]+", "[, ]+",
RegexOptions.None);
// find all matches in the string
MatchCollection ms = Regex.Matches(inputRegex, searchExpression);
This will do exactly what you need.
Jesse