Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex to find at least 4 occurrences of forward slash in string

Tags:

regex

I have some urls and I would like to make sure they have at least 4 forward slashes as some of my URLS have less. For example:

Pass: http://localhost:2000/machine/my-test-machine/3

Fail: http://localhost:2000/my-test-machine

Any help would be much appreciated. Thanks Dave

like image 669
dave Avatar asked Dec 07 '25 02:12

dave


1 Answers

You can try following regex,

\/\/(.*\/){3}

Working Demo

like image 52
apgp88 Avatar answered Dec 08 '25 16:12

apgp88



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!