Javascript .charAt(0) gives unexpected results -


  var वर्ग = "ए ()"; अगर (category.charAt (0) == / ^ [a-zA-Z] + $ /) {/ * यह भाग निष्पादित नहीं होता है / / * if condition के साथ समस्या है? * /} < / code>   

आप एक नियमित अभिव्यक्ति के उदाहरण के साथ अपने चरित्र की तुलना कर रहे हैं आप वास्तव में नियमित अभिव्यक्ति के साथ अपने चरित्र का परीक्षण करना चाहते हैं।

आप ऐसा कर सकते हैं:

  var category = "a ()"; अगर (/^[a-zA-Z]+$/.test(category.charAt(0))) {// अब इसे निष्पादित किया जाएगा}   

जावास्क्रिप्ट regex पर अधिक पढ़ने स्वाद:


Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -