0

I need some help whit the optimization of this group of characters [qwertyuiopasdfghjklzxcvbnmàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ] obviously it is really big so I need it smaller so I can use it into a regex, like this:

let N = /^N1\d{14}[^qwertyuiopasdfghjklzxcvbnmàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ]{78}$/;

I tried examples from other sites and this one too but didn't work as expected, can some one help me?

This regex is supposed to match a type of register like this one:

Register

N108258594000135255240708     315370        BLABLA BLABLABL BLAB BLA                          
Lagaggio
  • 39
  • 8

1 Answers1

0

Why are you negating the character group ? Isn't it better to enumerate the characters that can appear instead of those that mustn't ?

This would be a much cleaner regex:

let N = /^N1\d{14}[ 0-9A-Z]{78}$/;
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
  • Because those 78 must be all in uppercase and without any type of accentuation or lowercase, but especifically ```can't``` match ```those``` characters – Lagaggio Feb 18 '20 at 19:42
  • @Lagaggio Yes, just because they must be all uppercase without accentuation or lowercase, my solution is better. It does allow only uppercase letters, numbers and spaces. It is impossible to enumerate all accentuated letters. Look into Unicode... – Lorenz Meyer Feb 18 '20 at 19:59
  • But is it going to allow me to introduce a ```?```, ```|``` or a ```!``` ? – Lagaggio Feb 18 '20 at 20:11