I am trying to write a regexp (javascript) to validate a string where slashes are repeated.
Must be:
/ - valid string
/abs - valid string
/abs/ - valid string
/abs/a - valid string
// - invalid string
//asd//sd/ -invalid string
/as//a - invalid string
a/a - invalid string
abs - invalid string
////////sdf///// - invalid string
I am trying this regexp:
(\/){1}[\w-]*
^(\/){1}[\w-]*
^(\/\w+)+(\.)?\w+(\?(\w+=[\w\d]+(&\w+=[\w\d]+)*)+){0,1}$
How do I write an expression to pass the validation criteria?
regexfor such a simple task. If I understood your examples correctly, the input string is invalid if it contains two consecutive slashes. UseString.includes()to find if the input string contains the substring'//'.