Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Capture / Extract text between two words

Last post 06-18-2009, 4:49 AM by nirvana74v. 3 replies.
Sort Posts: Previous Next
  •  06-16-2009, 8:24 AM 53974

    Capture / Extract text between two words

    Hi

    I am trying to extract all the text between two words from the following text

                    4644485 Connect prod@64.151.xx.xx on
                    4644485 Init DB gWire
                    4644485 Query   select id, name, description, main_image, back_image, ad_image, ad_url, moderated, start_date, end_date, user_id, username, lo
    cation, category, email, url, pretty_url, turl, creation_date, featured, last_post_count, address, address2, city, state, zip, country from event where id=
    944
                    4644485 Quit
                    4644486 Connect prod@64.151.xx.xx on
                    4644486 Init DB gWire
                    4644486 Query   select max(pub_date) 'lastupdated' from feed_item where  event_id in (944) AND hide <> 'true'
                    4644486 Query   select id, title, link, description, author, image, guid, event_id, event_name, event_location, event_url, event_user_id, even
    t_username, source, source_name, keyword, pub_date, featured from feed_item where pub_date<='1244003800' and event_id=944 AND hide <> 'true' ORDER BY pub_date
     DESC LIMIT 0,15
                    4644486 Quit
     

    I have written

    (?:Connect)((.*?\n)+)(?:Quit)

    I want the text between Words Connect and Quit to be captured but it doesn't. I know I am making a mistake somewhere but am not able to figure it out.

    Thanks for the help in advance.

  •  06-16-2009, 2:18 PM 53984 in reply to 53974

    Re: Capture / Extract text between two words

    (?is)(?<=Connect).+?(?=Quit)

     

    Your problem is that you expect Quit right after \n


    http://portal-vreme.ro
  •  06-18-2009, 1:07 AM 54060 in reply to 53984

    Re: Capture / Extract text between two words

    Thanks Killahbeez,

     Now I have another problem, I would like to extract only Queries, so if we see the second block there are 2 lines having Query, I would like each query to be extracted, how can we do that.

     

    Thanks

  •  06-18-2009, 4:49 AM 54069 in reply to 54060

    Re: Capture / Extract text between two words

    have been able to do that

    (?is)((?<=Query)\s+).+?(?=[0-9]+)

View as RSS news feed in XML