regex - regular expression which should allow limited special characters -
can 1 tell me regular expression textfield should not allow following characters , can accept other special characters,alphabets,numbers , on :
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ @ &
this not allow string contains of characters in part of string mentioned above.
^(?!.*[+\-&|!(){}[\]^"~*?:@&]+).*$ brief explanation
- assert position @ beginning of line (at beginning of string or after line break character)
^ - assert impossible match regex below starting @ position (negative lookahead)
(?!.*[+\-&|!(){}[\]^"~*?:@&]+)- match single character not line break character
.*- between 0 , unlimited times, many times possible, giving needed (greedy)
*
- between 0 , unlimited times, many times possible, giving needed (greedy)
- match single character present in list below
[+\-&|!(){}[\]^"~*?:@&]+- between 1 , unlimited times, many times possible, giving needed (greedy)
+ - the character "+"
+ - a "-" character
\- - one of characters
&|!(){}[” «&|!(){}[ - a "]" character
\] - one of characters
^"~*?:@&” «^"~*?:@&
- between 1 , unlimited times, many times possible, giving needed (greedy)
- match single character not line break character
- match single character not line break character
.*- between 0 , unlimited times, many times possible, giving needed (greedy)
*
- between 0 , unlimited times, many times possible, giving needed (greedy)
- assert position @ end of line (at end of string or before line break character)
$
Comments
Post a Comment