Regular expression

I want to check this part in a string:   -sale- or -mark-  , always four characters

12321321-sale-report
12321321-sale-csv
12321321-sale-xls
12321321-mark-report
12321321-mark-csv
12321321-mark-xls
 
byte1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

CodeCruiserCommented:
You can use the string.contains method.

If str.contains("-sale-") or str.contains("-mark-")
0
byte1Author Commented:
i need to use that in a switch case statement.
0
CodeCruiserCommented:
Do you HAVE to?

May be

Select str.Contains("-sale-")
Case true
   ...
Case false
   ...
End Select
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

AshokSr. Software EngineerCommented:
Here is what you need.

\b(sale|mark)(?:\W+\w+){1,6}?\b

It is tested with
12321321-mark-report
or
12321321-sale-report

HTH
Ashok
0

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
Terry WoodsIT GuruCommented:
or possibly just:
\b(sale|mark)\b
0
AshokSr. Software EngineerCommented:
\b(sale|mark)(?:\W+\w+){1,4}?\b

Above also works!
0
AshokSr. Software EngineerCommented:
\b(sale|mark)(?:\W+\w+)\b

Above also works!
0
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
ASP.NET

From novice to tech pro — start learning today.