Phonebook application - Enhacing search capabilities

I have this phonebook application developed through this TA, the latest version at

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28645108.html

I have modified the data in this file and would like to enhance the search capability.

Currently the search looks for the string anywhere in the data field.

I would like to have a checkbox called "Whole words" which, when unchecked, works just as it does now.

When the checkbox is checked the search should look at whole words or numbers. So that ro would match Rory and not broomee. I think the delimeters for a word or number should be
space
comma
hyphen

There could be more but I think I can add that later.
PhonebookEEv5.0.xls
LVL 43
Saqib Husain, SyedEngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
ro would match Rory and not broomee
I wouldn't call that a Whole word match but more a beginning of word match. Anyway, that's what I implemented using a regular expression. A small change (checking for another boundary at the end) would make it a Whole word match.

I think the delimeters for a word or number should be: space, comma, hyphen. There could be more but I think I can add that later.
There is a standard notation in regular expressions for word boundaries: \b. I haven't checked which characters that uses but in practice it has never let me down. In case you don't want to use it I left a comment in the code with an alternative.
PhonebookEEv5.1.xls
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Saqib Husain, SyedEngineerAuthor Commented:
I wouldn't call that a Whole word match but more a beginning of word match

I agree but what I wanted was something short to write in there.

Thanks, looks good now.
0
Saqib Husain, SyedEngineerAuthor Commented:
HI, again, I just discovered that  the underscore is not considered a word separator. I cannot pick Chris_Bottomley  by typing B. Can you do something about it?
0
Robert SchuttSoftware EngineerCommented:
Yes sure, couple of options. In the userform code (line 19) you could specify "standard word boundary or underscore":
re.Pattern = "(\b|_)" & strInput ' "(^|[ ,_-])"

Open in new window


The comment there shows the alternative I mentioned earlier where you only allow the exact characters you want. Just make sure the "-" is the first or last character within the range (block quotes) because otherwise it changes the meaning to a range of characters.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.