need regex help to remove numbers and trailing slash

I need some coding help... I have a string, for example:

$string = "post-title/367895378/";

The numbers there... in the string they always start with 367 and then there are anywhere from 3 to 6 digits afterwards.

I need to remove the "367" and all the numbers afterwards, and the trailing slant, so that the string ends up as "post-title/" (the post title changes based on the page it's on, of course).

The numbers starting with 367... and the slant are always going to be at the end of the url, so everything starting with 367 and afterwards should be eliminated.

I know that needs some kind of regex, but that's beyond my skills...


Who is Participating?
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.

St_Aug_Beach_BumAuthor Commented:
Got it, regex not needed....

echo strstr($string, 'By', true) ?: $string;

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
Chris StanyonWebDevCommented:
If your rules really are as simple as that, then you don't really need a regex. Just search for the first / and substring on that:

$string = "post-title/367895378/";
$result = substr($string, 0, strpos($string, "/") + 1);

Open in new window

If your rules are more complicated, then you might want to explain all possible variations of $string.
Chris StanyonWebDevCommented:
Your solution won't give you the trailing slash !!
St_Aug_Beach_BumAuthor Commented:
Got it Chris, thank you!
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
Regular Expressions

From novice to tech pro — start learning today.