Friday, 9 August 2013

How can search a string to see if it contains all substrings?

How can search a string to see if it contains all substrings?

I will be using coffeescript/javascript/jquery and I need to return true
if a string contains all of my substrings.
So, lets say that I have an array of substrings 'my', 'dog', 'spot'. I
need to return a true if my string is 'growing up my pet dog was named
spot'. But I would need to return false if the string was 'I had a dog
named spot'.
I am thinking there is a way to do this with a regular expression, but
can't seem to figure it out?

No comments:

Post a Comment