i am getting the following regex from a json from server
regexval = ^[A-Za-z\\'\\s\\.\\-\\,]{1,50}$
there is a problem with this regular expression it has a ' which is breaking my js code to test this regular expression. how do i make this a valid regex?
im doing something like this to test it
if(!regexval.replace(/\\/g,"\\").test(inputVal)) {
}
EDIT
following is the JSON
[
{
"ExtensionData": {},
"Data1": null,
"DisplayName": "First Name",
"IsRequired": true,
"LengthValidation": 0,
"Name": "ServiceFirstName",
"RegexValidation": "^[A-Za-z\\'\\s\\.\\-\\,]{1,50}$",
"Type": "String",
"ValidationMessage": "The field 'First Name' doesn't meet the format requirements"
},
{
"ExtensionData": {},
"Data1": null,
"DisplayName": "Last Name",
"IsRequired": true,
"LengthValidation": 0,
"Name": "ServiceLastName",
"RegexValidation": "^[A-Za-z\\'\\s\\.\\-\\,]{1,50}$",
"Type": "String",
"ValidationMessage": "The field 'Last Name' doesn't meet the format requirements"
}
]
',s,.,-, and,var regexval = /^[A-Za-z\'\s.\-,]{1,50}$/;.