Sesame Sesame - 2 years ago 102
Javascript Question

Find character pattern using regex

I am trying to find all occurrences of a special character

surrounded by either letters or numbers.

After many tries, I have come up with the following Regex that almost does what I need:


This works fine for these examples:


However, it fails if there are two forward slashes together:

In this case, it matches the second forward slash after
which I do not want.

How can I modify this Regex to meet my needs?

EDIT: I do not want to a match when two forward slashes are together. I only want to match if a single forward slash is surrounded by alphanumeric characters.

Answer Source

you would need a positive lookbehind group, like so:


however, according to it is not supported in javascript.

Works fine in e.g. python

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download