我需要正则表达式,以便只允许这些字符输入:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9& ,。 - /()@ * +! ? “':;
如果我可以在这段代码中通过jQuery实现它,那将是很好的:
$("#firstText").keyup(function () {
var value = $(this).val().toUpperCase();
$(".zetin16").text(value);
}).keyup();
答案 0 :(得分:0)
^[A-Z0-9&,.\/()@*+!?“‘:;-]+$
此正则表达式将执行以下操作:
ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&,.–/()@*+!?“‘:;
现场演示
https://regex101.com/r/bO2zN4/1
^ assert position at start of a line
[A-Z0-9&,.\/()@*+!?“‘:;-]+ match a single character present in the list below
A-Z a single character in the range between A and Z (case sensitive)
0-9 a single character in the range between 0 and 9
&,. a single character in the list &,. literally (case sensitive)
\/ matches the character / literally
()@*+!?“‘:;- a single character in the list ()@*+!?“‘:;- literally
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
$ assert position at end of a line