First you have to start with what your employer does:
var a = '[^+][a-zA-Z]'
var reg = new RegExp(a);
console.log(reg.test('aA'));
console.log(reg.test('+aA'));
This searches for any match in a string that contains: [cualquier caracter que no sea '+']
and [cualquier caracter que esté entre a-z o A-Z]
Some examples of strings that your pattern will find: 'aF', 'eC', '3V', '.a'
In this league you can see the patterns that the expression finds, plus I use it a lot when I work with regular expressions: link
Now your first question: Escape or not the plus sign: [^\+]
?
As such it is not necessary since if you do the test both expressions are equivalent and will give you the same result:
var a = '[^\+][a-zA-Z]'
var reg = new RegExp(a);
console.log(reg.test('aA'));
This is mainly because within that expression the plus sign is taken as it is, a plus sign character, and not as a quantifier like a regular expression used to use it, for that this element would have to go to the right of some character where you need to look for one or more, or to the right of an expression where you also need to look for one or more example:
var a = '[^+]+[a-zA-Z]'
var b = '[^+][a-zA-Z]+'
var reg = new RegExp(a);
var regB = new RegExp(b);
console.log(reg.test('aaA'));
console.log(regB.test('icCdfe'));
Here is also the example in the league with pattern b of this example, and if you look now you look for longer strings, for the quantifier +
: link
The second question: Use ^ y $
?
These symbols indicate to the expression the beginning and the end of the chain that the expression should look for, what we must emphasize here is that you are giving a beginning and an end, so anything that is before or after your string that you are looking for will cause your expression not to find it when not complying with the patterns, example:
var a = '^[^+][a-zA-Z]$'
var reg = new RegExp(a);
console.log(reg.test('aA'));
console.log(reg.test('+a')); //Caracter '+' por lo que falla
console.log(reg.test('+aA')); //Caracter '+' pero usas ^$ por lo que aún falla, aunque en los primeros ejemplos si funcione
With this we can say that when using ^ $
you set the search pattern to a result and that it is exact and meets the condition of the expression, not to use it as in the first examples, even if it finds a plus sign , keep finding a couple of characters that meet your condition and the test returns you true