Skip to main content
Inspiring
September 24, 2009
Question

Need to extract words within brackets

  • September 24, 2009
  • 1 reply
  • 809 views

I have a table in a database called body.  About 1000 records.  Everyone of these records have at least a paragraph or 2 in them.  In these paragraghs are words surrounded by brackets, ex. [[ethanol]] .  I need to extract these phrases with-in these brackets and put these keywords in a seperate table to use as auto suggust.  How do I loop through the database and get these words, I know I can remove the brackets after I get the words but how do I extract the words from the pargraphs?

Anthony

    This topic has been closed for replies.

    1 reply

    Inspiring
    September 24, 2009

    It's a bit hard to answer this without knowing what DB system you're running.  But I will sy this: the best solution is probably going to be to do it entirely on the DB side of things, rather than dragging the stuff down to CF, monkeying with it, and popping it back up to the DB.  Unless you're using someing rubbish like Access, then your DB system will provide all the functionality you need, so there's no need to involve CF at all.  You could do it with CF, but it's not really what CF is designed for, whereas the DB itself is designed for doing this sort of thing.

    So if I was you I'd look at what string manipulation your DB system offers, looking specifically at regex-oriented functions as a starting point.  You should be able to pull the keywords out of each record with one regex match if you're lucky.  If the regex support is less good, then doing it with a loop and a find & some substring extracts shouldn't be too hard.

    However the ins and outs of how to do it on your DB of choice is probably a conversation best had on a DB-specific forum, if you can find a good one.

    --

    Adam

    AJBJAuthor
    Inspiring
    September 24, 2009

    The database is MS Sql.

    Does any one have a easier answer on how to accomplich this.  I am not an expert using MS Sql.

    BKBK
    Community Expert
    Community Expert
    September 26, 2009

    MS SQL has an entire module dedicated to this purpose. It comes at no extra cost. Search the web for Full Text Search.