I am creating a binary calculator and I would like to create a regular expression to match the operands and a single operator. The regular expression that I've created works correctly for everything except the backslash \
character. Here is my regular expression:
re = /^([10]+)([\+\-\*\\]{1})([10]+)/;
re.test('11001+1000');
// true
re.test('11001-1000');
// true
re.test('11001*1000');
// true
re.test('11001\1000'); // I WOULD THINK THIS WOULD WORK
// false
re.test('11001\\1000'); // I WOULD THINK THIS WOULD FAIL
// true
re.test('11001++1000');
// false
Can anyone advise me on what I am doing wrong?