473,480 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Seach for whole word with ASP / /MS Access

Is there a way to get records containing a whole word? I've heard regular
expressions can do it, but I can't make one work in an ASP / MS Access SQL
Query

sSQL="SELECT PageTitle FROM Pages WHERE PageTitle LIKE '%cat%' "
rs.open etc

returns scatty, catatonic etc. Thanks for your help
Giles

Jul 22 '05 #1
3 1726
where PageTitle like '% cat %'
--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Giles" <Gi***@NoSpam.com> wrote in message
news:uK****************@TK2MSFTNGP10.phx.gbl...
Is there a way to get records containing a whole word? I've heard regular
expressions can do it, but I can't make one work in an ASP / MS Access SQL
Query

sSQL="SELECT PageTitle FROM Pages WHERE PageTitle LIKE '%cat%' "
rs.open etc

returns scatty, catatonic etc. Thanks for your help
Giles

Jul 22 '05 #2


"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:eb****************@TK2MSFTNGP14.phx.gbl...
where PageTitle like '% cat %'


But that won't return records containing " cat!" or " cat," or " cat." etc.

Not sure there is a way of doing it without using lots of OR clauses to
cover the above cases. Certainly not going to be a speedy query.

--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
Jul 22 '05 #3
Giles wrote:
Is there a way to get records containing a whole word? I've heard
regular expressions can do it, but I can't make one work in an ASP /
MS Access SQL Query

sSQL="SELECT PageTitle FROM Pages WHERE PageTitle LIKE '%cat%' "
rs.open etc

returns scatty, catatonic etc. Thanks for your help
Giles

The surest way to do this would be to create an "index" table. I would not
perform this task in asp. VBA code would be best. You can use Windows
Scheduler to casue the task to run periodically. you should ask in an Access
newsgroup for details about running VBA code from the command-line used to
open your database in Access.

Here are the bare bones (this is untested "air" code) of what this task
would do (I'm assuming your table has an autonumber PageID field ...):

First create the PageIndex table. It should have two fields: PageID and
Words

Sub RebuildIndex()
dim cn as adodb.connection
dim rs as adodb.recordset
dim cmd as adodb.command
dim ar as variant
dim arParms as variant
dim sSQL As String,
dim data as string
dim i as integer

set cn = Application.CurrentProject.AccessConnection

'first, clear the pageindex table:
cn.execute "delete from PageIndex",, _
adCmdText + adExecuteNoRecords

set rs = new adodb.recordset
rs.cursorlocation=adUseClient
rs.Open "Select PageID, PgeTitle FROM Pages", cn,,,adCmdText
set rs.activeconnection=nothing
sSQL = "INSERT INTO PageIndex (PageID, Words) VALUES(?,?)
set cmd=new adodb.command
cmd.activeconnection=cn
cmd.CommandText=sSQL
do until rs.eof
data=rs(1)
data = replace(data,"."," ")
'repeat to remove the other punctuation marks
'hopefully somebody wil jump in with a regexp patrern to
'replace them all in one shot

'Optionally, use regexp to eliminate "nuisance" words, such as articles

ar=Split(data, " ")
for i = 0 to ubound(ar)
arParms=Array( rs(0) , ar(i))
cmd.Execute ,arParms,adCmdText + adExecuteNoRecords
next

loop

End Sub
Now, querying for specific words will be as simple as:
select DISTINCT PageTitle
FROM Pages p INNER JOIN PageIndex i
ON p.PageID = i.PageID
WHERE Words = "cat"

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1855
by: Lord Khaos | last post by:
If I am trying to find an expression, foo, I can do something like this: rExp = /foo/gi; if(results.search(rExp) > -1){ and all work fine. however, if I want my search term to be a...
8
3478
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
4
1387
by: Filips Benoit | last post by:
Dear All, I want to seach the code of all forms for a string. My code below only works for open forms. I want it to work for all forms. See *** Problem line **** Thanks,
4
5292
by: Mark | last post by:
Hi all, I have a query which returns 56 results every time. 1 field of the query contains the results of an expression where 55 will contain decimal points and 1 will be a whole number. Is there a...
0
1316
by: leeonions | last post by:
Hi there, i am trying to use regular expressions to search through a text string and replace a given whole word. take the string = "The matsat on the mat!" (bad example i know) i want to...
2
11087
by: leeonions | last post by:
Hi there, i am trying to use regular expressions to search through a text string and replace a given whole word. take the string = "The matsat on the mat!" (bad example i know) i want to...
4
3582
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the...
4
4774
by: seannakasone | last post by:
Is there a way to search a string for a whole word w/o using a regular expression? i.e. mystring.IndexOf(mypattern, *WholeWord); The reason i rather not use a regular expression is because...
8
2147
rpnew
by: rpnew | last post by:
HI, I'm working with PHP/MySql... on one page i've used this XMLHttprequest object. Now i'm developing the system on FC4/FireFox.. on my machine it works fine but if i try to access it from...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6737
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5336
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.