There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Emulating a vBulletin/Google-type search string parser in VBA


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
cristobal03's Avatar
Distinguished Member with 2,991 posts.
 
Join Date: Aug 2005
Experience: Advanced
12-Dec-2005, 02:12 PM #1
Emulating a vBulletin/Google-type search string parser in VBA
Hey all, my first thread in the Developer forum. I'm basically looking for some feedback.

I'm not looking for a search algorithm, mind. Just a parsing algorithm to handle the search terms. So far I've come up with four basic types of searches (or three if you don't count SoundEx searches):

"literal" -excluded [SoundEx] contains

That is, anything in double-quotes looks for an exact match; anything preceded by a hyphen cannot be matched; anything contained within brackets is matched using SoundEx codes (the bracket convention is specific to my application and is not as far as I know a standard search parser convention); and anything else--split at whitespace--is generally matched as a basic substring.

My idea is to break a search string into an associative array that is sort of bitmasked. Each binary key would represent a type of search, a la

Code:
Public Enum stSearchType
  stLiteral = 1
  stContains = 2
  stExcludes = 4
  stSoundEx = 8
End Enum
So that for array SearchArray(8, n),

Code:
SearchArray(1, n) ' all the search criteria falling within quote wrappers
SearchArray(2, n) ' all the unspecified search criteria
SearchArray(4, n) ' all the search criteria matching a "* -?*" pattern
SearchArray(8, n) ' all the search criteria falling within brackets
I thought I might go through the input string in chunks, but the more I think about it, the more I believe I should go one character at a time. VBA is worth about diddly when it comes to regular expressions, and its String object class doesn't have robust methods. Therefore, in order to match opening code characters (i.e., ", [, and Like "* -?*") against their closing character counterpart, I think I need to process the characters one at a time. That's what I'm currently doing, but it seems like a mediocre algorithm at best.

Does anyone have other suggestions, or experience in trying to emulate this kind of functionality? Unfortunately the language has to be VBA; if you know of similar logic, I'd be interested because I might be able to port it.

Thanks,

chris.

Last edited by cristobal03 : 12-Dec-2005 02:41 PM.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:25 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.