I'd like to implement this pattern on a regexp but I can't succeed making it work as I would like it to pattern:
var strInput = $("#inputFilter").val();
var pattern = new RegExp("(#[a-z0-9]{3,})|(@[a-zA-Z0-9]{6,16})|([a-zA-Z0-9]{6,16})(,((#[a-z0-9]{3,})|(@[a-zA-Z0-9]{6,16})|([a-zA-Z0-9]{6,16})))*");
var result = pattern.test(strInput);
if (!result)
{
alert("Must follow this pattern, order is not relevant, e.g Title,#tag,@Username or Title,#tag,@Username,#tag2");
return
}
should match:
#hello
helloWorld
@HelloUser
#hello,@HelloUser,HiWorld
@HelloUser,HiWorld,#hello1,#hello2
should NOT match:
#@hello
#hi
@Hello
@HelloUser#hello
thanks for help
Aucun commentaire:
Enregistrer un commentaire