Click here to Skip to main content
15,566,160 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hello, I have a massive problem in regular expression in search. Well I have a textbox and a button, here the code I put in the button event for the search by using regular expression:

The problem I'm having is, I want search a mistyped word from letter A to Z both in lower and upper-cases. Of course if the word is exact then good, else it will display all words begins by the letter. Is the code good?
Posted
Updated 5-May-11 14:12pm
v3
Comments
Graham Shanks 16-Apr-11 16:21pm    
I cannot understand what you want to do. The code will extract the individual words in the textbox. Perhaps an example of what you mean by "a mistyped word from letter A to Z both in lower and upper-cases" would help

1 solution

You are assuming that it will return matches in your code. I would change your code slightly to allow the test of successfully finding matches.

Here is an example to test for matches

VB
dim SearchData as string = txtSearch.text.trim
dim RegExString as string = "\b\w*[a-z]\b"
dim RegExMatch as match = Regex.Match(SearchData, RegExString)

if RegExMatch.sucess = true then
 '... do what you need to do here.
end if
 
Share this answer
 

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