1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rexexp search

Discussion in 'MySQL' started by lektrikpuke, May 5, 2012.

  1. #1
    Select * from table where field_name REGEXP 'role>\n.*status>TERMED<'

    I'm trying to parse xml that I've stored in a field using regexp. role> should be followed by a newline and then <status>TERMED< would be on the very next line. The query I have listed above doesn't work. Any suggestions?
     
    lektrikpuke, May 5, 2012 IP
  2. lektrikpuke

    lektrikpuke Active Member

    Messages:
    272
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    63
    #2
    SELECT * FROM table WHERE field_name REGEXP 'role>\r\n[\t*| *]<ns:status>TERMED<' turned out to be the answer. Didn't realize the \r's were there (even though I should have).
     
    lektrikpuke, May 6, 2012 IP
  3. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #3
    koko5, May 6, 2012 IP
  4. lektrikpuke

    lektrikpuke Active Member

    Messages:
    272
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    63
    #4
    I tried xml functions but couldn't get it to work. The regexp works, but it would be nice to get xml parsing to work, too. SELECT * FROM table where EXTRACTVALUE(id_xml, '/ns:customer/ns:status') = 'TERMED'";
    ????
     
    lektrikpuke, May 6, 2012 IP