PowerShell实现在字符串中查找大写字母(powershell input)干货分享

随心笔谈11个月前发布 admin
94 0


$text=’here is some text with Uppercase letters’

$c=0
$position=foreach ($character in $text.ToCharArray())
{
$c++
if ([Char]::IsUpper($character))
{
$c
break
}
}

if ($position -eq $null)
{
‘No uppercase characters detected.’
}
else
{
“First uppercase character at position $position”
$text.Substring(0, $position) + “<<<” + $text.Substring($position)
}

© 版权声明

相关文章