I've almost got this regex working but am having trouble with the leading forward slash - can anyone see where I'm going wrong with this? I just want to extract the first string "projects
" from this example
/projects/personal/29/56
see also here -> http://regexr.com?300av
The easiest way is to split string using forward slash
var firstString = url.split('/')[1];
and you will have first string, but if you want to extract using regext than this will do, just remember don't add global parameter in your regex.
\/([a-zA-Z0-9]{0,})
I hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With