jeudi 11 juin 2015

XML pattern to JS regex

I have a form that generate an XML file validated by a XSD schema.

In the XSD there are a lot of rules (pattern attribute).

For example,

pattern: [\p{L}\d\s\.,\[\]\{\}€@#\-\(\)/='\+:\?!"%&\*;<>]*

documentation : type A : all letters, all numbers, space, dot, comma, \[ \] \{ \} € @ # \- \( \) / = ' \+ : \? ! " % & \* ; < >

I thought this kind of pattern would be the same thing that JS regex and that I could validate my form easily with it. Big mistake, this is not the same thing (I tried with js replace() and html pattern attribute and it's not working). I have hundreds of field types to validate in JS using the same rules.

Do you know a way to convert this kind of pattern to a JS regex ?

Aucun commentaire:

Enregistrer un commentaire