I am trying to match strings that contain 4 characters separated by |
Works fine in java when I use "(\\w{1,4})(\\|(\\w{1,4}))*"
When I use same pattern in jquery it does not match:
$.validator.addMethod("nameId",function(value,element){
return this.optional(element) || /^(\\w{1,4})(\\|(\\w{1,4}))*$/i.test(value);
},"Please enter valid input.");
Can anybody let me know how to do this in jquery.
Thanks!
My guess is because you include the double backslashes. If you change
\\wto\wand etc., does that fix the problem?