In my Angularjs application, I need to have a regex for two patterns to validate the form with the following condition.
Sample 1:
The input field must take an alphanumeric value without a space, and it must also allow the user to use type characters ~!@#$-_anywhere on the line, except that these characters, except for other characters, must be resolved as (%, &, ^ etc). It should also not allow for leading / closing spaces.
Examples:
ab@4_w : valid
sd!tye123 : valid
sd%tye123 : Invalid
sd*tye123 : Invalid
$ scope.pattern1 = [\ w ~! @ # \ $ -] +
Sample 2: Only an alphanumeric number must be allowed without a space and other characters, including (_). It should also not allow for leading / closing spaces.
Examples:
a4hgg5 : Valid
a4_6hy : Invalid
a@yb : invalid
$ scope.pattern2 = [\ w] +
$scope.pattern1 $scope.pattern2 , .