?
Solved

How to find contents of a table in a string

Posted on 2008-06-11
4
Medium Priority
?
196 Views
Last Modified: 2013-12-17
Given a string, usually a long sentence, how will I know if the contents of my table is part of that string.

ex. string = "the quick brown fox jump over the lazy dog"
myTableContents = dog, cat, fox, pig

I wanna get all the words from the string that exists in my table.  How will I do that using C#.net, and I'm using Access database.

0
Comment
Question by:meredithf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
miketob earned 375 total points
ID: 21762782
Use the split method to separate your sentence into words, it will result in an array of words, then cycle through this arry serching for each word in your table.

Regards

0
 
LVL 6

Expert Comment

by:Bruce_1975
ID: 21766851
Just to give you an other idea
Regards,
Bruce
string givenString = "the quick brown fox jump over the lazy dog";
foreach (string item in myTableContents)
{
    if (givenString.IndexOf(item) > -1)
        Debug.WriteLine(item + " is included");
}

Open in new window

0
 

Expert Comment

by:bmoabc
ID: 21772833
You can also return the resuts of a simple SQL if your table contents are unique records

SELECT table.[myTableContents]
FROM table
WHERE ((("sentence" Like "*" & table.[myTableContents] & "*")=True));

This will provide all the records send it to an array or another query, whatever you need...
0
 

Author Comment

by:meredithf
ID: 21809933
Thanks miketob for the idea.  It works.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question