troubleshooting Question

Very simple regex-curiosity question

Avatar of bamapie
bamapie asked on
Regular Expressions
5 Comments1 Solution184 ViewsLast Modified:
I guess the forward slash doesn't mean what I thought it meant.  And I thought it meant nothing.

Let's say I have a URL like:

and I search this string for the regex /162/.

I thought that would match.  It doesn't.

regex 162 DOES match.

So what exactly do the forward slashes here mean, and why did my including them kill my ability to match?

What I am really wanting to do is the equivalent of *162*.  But I know that I probably don't need to tell regex [wildcard]162[wildcard], so in my feeble regex memory, I thought I had to use slashes to indicate that this is the pattern I'm trying to match anywhere in the text.

I'm basically fooling around and trying to do a string .contains, but using regex.  Meaning, just simply checking the source text to see if it contains a substring.

Dr. KlahnPrincipal Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros