find a string in a sentence using regex

Hi,
Would like to find a string in a sentence using regex
Basically I have two variables similar to below and valuate true or false
VAR1=”NY,CO,NJ,FL”
VAR2=”NY”

Thanks in advance
enthuguyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
What is the string you want to find, what is the sentence you want to find in, and what shell are you using to do it?
enthuguyAuthor Commented:
Sorry

Find var1 in var2
ozoCommented:
#!/usr/bash
VAR1="NY,CO,NJ,FL"
VAR2="NY"
[ "${VAR1/$VAR2/}" != $VAR1 ] && echo found $VAR2 in $VAR1

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

enthuguyAuthor Commented:
Sorry other way around

Find var2 in var1
enthuguyAuthor Commented:
Thx ozo,  is this using regular expression?
ozoCommented:
It uses pathname expansion.  
Regular expressions did not seem to be needed to accomplish what you seemed to be asking for in this case.
Is there another example that needs regular expressions?
enthuguyAuthor Commented:
I think i can use this as well
Thanks ozo
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.