From: Mark Henderson 
> Sent: Thursday, 26 July 2007 10:19 a.m.
> To: CF-Talk
> Subject: Regex help with search strings
> 
> Hi
>  
> I have a search box that currently contains only one field. I 
> normally have one input for first name, one for lat name and 
> so on, which makes the task of searching somewhat easier. 
> However, in this scenario that is not the case. So, what I 
> want to do is split the search term entered into distinct variables.
>  
> An example - let's say someone enters "joe blogs" in the 
> search field (without quotes). I then want to be able to 
> parse it so that I have one variable for "joe" and another 
> for "blogs", which I can then search on since the database is 
> organised into first_name, last_name, maiden_name, email, 
> etc. The criteria for this will be the space between the names.
> This looks like a case for regular expressions. I know how to 
> use REFind to check for the space, but that's all so far 
> (I've spent some time on this, and even read the docs!). Can 
> someone help me here please? 

For some reason Outlook decided to try and send my previous post as HTML
when I have HOF clearly set in my address book to use plain text - my
apologies for that. Anyway, something like the following seems to work:

<cfset searchstringRight = REReplace(searchstring, "[a-z]+ ", "", "ALL")
/>
<cfset searchstringLeft = REReplace(searchstring, " [a-z]+", "", "ALL")
/>

But if there is something else I can or should be doing when checking
the field please let me know.

Mark

-- 
This message has been scanned for viruses and dangerous
content by ISPNZ's automated virus detection system,
and is believed to be clean.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:284678
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to