SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Searching for Text Between Strings

    I need help formatting a search query to exclude results found between two strings.

    Specifically, I am trying to search a vBulletin database for text in posts while excluding text within quote tags. So I want don't want any results that are between "[quote" and "[/quote]".

    Lets say I'm searching for "yellow". How would I format this to exclude all instances within the quote tags?

    Code:
    SELECT pagetext FROM post WHERE yellow
    It sounds like it would be a simple and common query, but I've been searching for hours and coming up with nothing useful.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It wouldn't be all that difficult to just remove the text between those two tokens, and then search it, but where it gets complicated is when you have a body of text that has nested sets of quote tags.

    [quote]
    foo
    [quote] bar [/quote]
    baz
    [/quote]

    I think the query would get really hairy if you tried to account for that case(and you probably need to).

    My thoughts are to either store a seperate copy of the text in the database without the undesired uoted text, or to do post query filtering in whichever programming language you're using(where you can better cope with parsing this nested structure).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •