Issues with REGEX and forward slashes

I am trying to clean up some data on my site and want to look for strings that contain a single slash followed by a group of numbers. Like this:

/1
/500
/2455
/1898
/966
etc.

The number trailing the slash can be of any length and any value.

I was able to use this regex to locate the strings: ([‘/’[0-9])

The issue that is is causing is that it is finding matches for dates like this: 1/2/2001, 12/11/2011, 3/5/1980.

I then attempted to tack on a counter the regex method like this: ([‘/’][0-9]){1}, but that did not seem to work.

Any ideas?

Does this get you closer?


preg_match_all('~([^0-9])\\/([0-9]+)~', $str, $matches);
var_dump($matches);

It matches patterns where there is a non-digit followed by a slash, then 1 or more digits.
So dates won’t match because they lead with a digit, but it will capture the space or other leading character.

Try the following pattern

$pattern = '#(\\B/[0-9]+\\b)#s';