how to match any string but not a string that starts with slash?

291 Views Asked by At

how to match any string but not a string that starts with a slash?

I'm using node js regex

that was my try but it didn't work

(?!\/s).*
2

There are 2 best solutions below

3
Slim Shady On BEST ANSWER

^[^\/] match everything except that starts with slash

^[^\/].* if you want to match the whole string

1
OmG On

You can using startsWith function:

if(!str.startsWith('/')) // true for your case