Stack Overflow Asked by lolozen on November 27, 2021
Hi I’d like to create a regex that check if my string starts with a /
but no matter where shouldn’t contains /!
so:
/xxxx
= true
/xxxx/yyyy
= true
/!xxxx
= false
/xxxx/!yyyy
= false
xxxx
= false
I tried this but it doesn’t seems to work:
^/(?!(/!)(.*|/!.*))*$
As /!xxxx
should also be false, the lookahead should be at the start of the string or else you will miss checking the leading /
.
To find /!
anywhere in the string, you could prepend .*
^(?!.*/!)/.*
Answered by The fourth bird on November 27, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP