I need to assign a regex object to an input element pattern attribute programmatically. Below is my current implementation:
var regex = /\d{5}/;
element.attr("pattern", regex.toString().slice(1,-1);
Is there a better way to do this without string manipulation?