我已經創建了TextArea的正則表達式(它支持符號和新行),現在我想在其中添加「必需」。意味着當我在TextArea上並使用TAB將其專注於其他領域時。所以我想在正則表達式中添加Required。這是正則表達式正則表達式幫助需要添加「必需」
"^[a-zA-Z]+[[email protected]#()'!,+\-=_:.&€£*%\s]+$"
我想在此正則表達式中添加Required字段。
謝謝。
我已經創建了TextArea的正則表達式(它支持符號和新行),現在我想在其中添加「必需」。意味着當我在TextArea上並使用TAB將其專注於其他領域時。所以我想在正則表達式中添加Required。這是正則表達式正則表達式幫助需要添加「必需」
"^[a-zA-Z]+[[email protected]#()'!,+\-=_:.&€£*%\s]+$"
我想在此正則表達式中添加Required字段。
謝謝。
At that time i am getting following error.
Uncaught SyntaxError: Invalid regular expression: /^[a-zA-Z]+[[email protected]#()'!,+\\-=_:.&€£*%\\s]+$/: Range out of order in character class
這是因爲\\-=
表示範圍從\
字符至-
,這是因爲out of order
-
在整理序列\
之前是有序的。
Main problem is its working for javascript for JAVA language I have to use
"^[a-zA-Z]+[[email protected]#()'!,+\\-=_:.&€£*%\\s]+$"
and this is not working in Java Script. means in Java i have to replace "\" by "\\" and thats not working in java script.
在JavaScript中,你可以使用相同的符號在Java中,只對那些不能使用文字符號/…/
,而是像"…"
的字符串。
console.log(RegExp("^[a-zA-Z]+[[email protected]#()'!,+\\-=_:.&€£*%\\s]+$"));
// "…" rather than /^[a-zA-Z]+[[email protected]#()'!,+\\-=_:.&€£*%\\s]+$/
AS是,表達式應該匹配的文本'Required'。請澄清。 – npinti
你能否清楚這一點:你是否希望使該字段成爲強制性的(即不允許空值)或者是否允許在textarea中輸入「必需」? – Stephan
你的正則表達式'^ [a-zA-Z] + [a-zA-Z0-9?$ @#()'!,+ \ - = =:':'*%\ s] + $'已經匹配'必需的'文本。問題是什麼? – anubhava