Forums Register Login

How do I do a partial word search?

+Pie Number of slices to send: Send
Hi all,

I have a customer's name as an attribute of a reservation object stored in my vector of reservation objects. My current search only does an exact match of a customer name. How do I do a partial word search eg. if my customer name is danielle and I only key in dan, how do i get it to return danielle?

Hope to hear from someone soon! Thank you!

+Pie Number of slices to send: Send
This page should be able to help.
[ April 01, 2005: Message edited by: Ken Loh ]
+Pie Number of slices to send: Send
erm sorry... I feel lost lookin at tt page.. if it's not too much trouble, could you please give me an example?

Thanks again!
+Pie Number of slices to send: Send
Just using String methods, try haystack.indexOf(needle) to see if a small string is included in a large one.

The Pattern reference given above is all about regular expressions. RegEx is great fun and can do very powerful pattern matching. It looks scary but is fairly easy to pick up by copying examples. Try this Sun Tutorial or google for others to get started.
+Pie Number of slices to send: Send
Stan's suggestion is good. indexOf() will suffice for your case ( and for many other cases).

If you're still keen in using regular expression from the link that I'd posted, you could use it with String's match() method.

After reading Stan's suggestion, I think you should just use indexOf() to keep things simple.

Originally posted by hrin kuek:
erm sorry... I feel lost lookin at tt page.. if it's not too much trouble, could you please give me an example?

Thanks again!

 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2481 times.
Similar Threads
B&S Booking and locking
how come i can't call my search method from my main method?
My search method is not working ( vectors)
Setting parameters with jsp:setProperty
Comparator
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:03:42.