Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要匹配一个第二个字母是“a”的字符串,我当前的正则表达式是: ^([^a-zA-Z]*[a-zA-Z][^a-zA-Z]*)a+ 但这比我需要的要少,我什至不知道它不匹配但你知道问题出在哪里,或者是否有更好的这样做的方式?例如我需要匹配这些:
^([^a-zA-Z]*[a-zA-Z][^a-zA-Z]*)a+
" kamcnn" ",.,ya..--/**+-00" "0 0 q a"
我匹配了我能想象到的每一个字符串,但我得到的结果仍然比我应该得到的要低。编辑:“字母”是指来自 [a-zA-Z] 类的字符。
尝试这个:
^[^a-zA-Z]*[a-zA-Z][^a-zA-Z]*a.*
如果第二个 ASCII 字母是,则匹配整个字符串a:
a
^ # Start of string [^a-zA-Z]* # Match any number of non-letters [a-zA-Z] # Match one ASCII letter [^a-zA-Z]* # Match any number of non-letters a # Match an a .* # Match whatever follows