#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Check 2nd word in sentence.


    Hello,
    I am looking for a Regex in javascript to check for 2nd word in a setence. for example
    "Try and find it and please let me know".
    here there are two "and" in sentence. i want a Regex that dosn't match the 2nd "and" (since the position is 2nd word in the sentence). but it has to match 5th "and", since it is not at position 2nd. Please help.

    Thanks...
  2. #2
  3. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,898
    Rep Power
    3887
    Sorry, I don't understand your question.

    Are you trying to check whether the second word in a sentence is also contained somewhere else? Or are you checking for a specific word ('and' in this example) and seeing if it's contained in the sentence in some position other than second?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    word contained in sentence other than second


    Originally Posted by ishnid
    Sorry, I don't understand your question.

    Are you trying to check whether the second word in a sentence is also contained somewhere else? Or are you checking for a specific word ('and' in this example) and seeing if it's contained in the sentence in some position other than second?
    Thanks for the reply and Sorry for the confusion, I am checking a specific word 'and', seeing if it's contained in the sentence in some position other than second
  6. #4
  7. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,898
    Rep Power
    3887
    I wouldn't use a regexp for this. I'd suggest splitting the string into its individual words, then checking the resulting array for 'and' (other than the second position).

IMN logo majestic logo threadwatch logo seochat tools logo