Regular Expressions: Match a or b (a|b) example

Problem:

Make a regular expression that matches I love cats and I love dogs but not I love logs.

Output:







Solution:


I love (cats|dogs)


2 comments :

  1. Thanks for posting the solution to this problem. Please do keep sharing more such basic problems and their solutions for all the beginners out there.

    ReplyDelete
  2. this would be really helpful for a programming student I learnt a couple of programming languages then gave up along the way I wish assignmentmasters.co.uk would match up to your skill keep up the good job

    ReplyDelete

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact