0

Hi I need a Simple Regular expression in PCRE format to match something like

(Child OR Children) AND toys
4
  • I only know the OR operator... Dont know how to use the And operator. Commented Feb 6, 2012 at 19:38
  • There is no AND operator -- it's implicit. Think of a regex as a long string of ANDs. Commented Feb 6, 2012 at 19:44
  • @MichaelM: You can use lookaheads and lookbehinds to get the effect of AND. See my answer for an example. Commented Feb 6, 2012 at 19:48
  • Thank you everyone for your reply. Commented Feb 6, 2012 at 20:20

2 Answers 2

3

The following, or a slight derivative of the following, should work for you:

/(?:child|children) toys/i
Sign up to request clarification or add additional context in comments.

Comments

1

Question is not very clear about how word toys will appear after OR condition, but I think following should work for you:

/(?:^|\b)child(?:ren|)\b.*?(?<=\btoys\b)/i

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.