in reply to YAREGEX for all

I want to match for example any string that has /data or /tmp in it
"In it" or "starts with"?

Your code, and all the replies so far have used "starts with". If you really meant "in it" you need to drop the '^'s from any of the fine examples given so far


Unless I state otherwise, my code all runs with strict and warnings