There is a field which accepts a-zA-Z for which I am using regEx which works fine as
/^[a-zA-Z\s]+$/
Now field should also except all chars except &,<,> I have modified the regEx to support this change and new regEx is
/^[a-zA-Z\s]+[/!@#$%^&*()]+$/
but looks like its not working.... Can someone advise what is wrong am I doing ?
Also, instead of adding all allowed special characters, can we add only special characters which are not allowed in RegEX ?
================================================================================= Validating the code in typescript using below code, It should work as suggested but still getting false for all input values...
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
private output ;
private regEx = new RegExp('/^[a-zA-Z\s/!@#$%^&*()]+$/');
private input = 'A';
constructor(){
console.log(this.regEx.test(this.input));
}
}