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

To get a word from a sentence after a particular word

Last post 11-20-2008, 4:21 PM by mash. 3 replies.
Sort Posts: Previous Next
  •  11-20-2008, 2:00 PM 48574

    To get a word from a sentence after a particular word

    Hi All,

    I'm a newbie to RegExp

    i need to get a word from a sentence after a particular word

    Eg) hi, NOT i  NOT love NOT toys

     

    (Here i need to get every word after the keyword "NOT" ) 

    output should be;-

    hi  i  love toys

     

    Thanks in advance,

    Sarav 

  •  11-20-2008, 2:11 PM 48575 in reply to 48574

    Re: To get a word from a sentence after a particular word

    "hi" does not come after "NOT".

    But, have you already tried something yourself? If so, could you post it and tell on what input it failed?

    Thanks.

  •  11-20-2008, 3:14 PM 48582 in reply to 48574

    Re: To get a word from a sentence after a particular word

    I tried with, 

    str = "hi, NOT i  NOT love NOT toys"

    str.scan(/NOT (.*?) /) 

    But i cant get the exact result. I need the words which are come after "NOT" .

  •  11-20-2008, 4:21 PM 48586 in reply to 48582

    Re: To get a word from a sentence after a particular word

    is the any particular reason you are trying to use a regex for this?  Why not just do a string replace and replace NOT with an empty string? 

    If your problem is more complex than that would you please read our Posting Guidelines http://regexadvice.com/forums/thread/47451.aspx and ask your question again following them as much as possible?


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
View as RSS news feed in XML