使用正則表達(dá)式可以檢查一個(gè)字符中是否包涵一個(gè)大寫字母:
$text1 = 'this is all lower-case'$text2 = 'this is NOT all lower-case' $text1 -cmatch '[A-Z]'$text2 -cmatch '[A-Z]'
結(jié)果將返回”true”或”false”
反過來檢查是否包含小寫,可以嘗試這樣:
$text1 = 'this is all lower-case'$text2 = 'this is NOT all lower-case'$text1 -cmatch '^[a-z/s-]*$'$text2 -cmatch '^[A-Z/s-]*$'
結(jié)果將返回”true”或”false”
總體來說,這次測(cè)試比較困難因?yàn)槟阈枰紤]所有字符的合法性。在這個(gè)例子中,我采用了從a到z的小寫字符串,空格和減號(hào)。
合法的字符串是嵌在“^”與“$”中間的(它表示行的開始和結(jié)尾)。星號(hào)代表量化前面任何合法字符串。
支持所有PS版本
|
新聞熱點(diǎn)
疑難解答
圖片精選