end of day 4 week 1

This commit is contained in:
2026-01-22 07:31:44 +01:00
parent 5120f11339
commit 82b79336ea
15 changed files with 247 additions and 0 deletions

24
week 1/day 4/exo4.ps1 Normal file
View File

@@ -0,0 +1,24 @@
$users = @("admin", "root1", "John_Doe", "Alice", "Bob42")
foreach($username in $users){
$badChar = $false
foreach($char in $username.ToCharArray()){
if($char -notmatch '[A-Za-z]' -or $char -eq ' '){
$badChar = $true
break
}
}
$firstLetter = $username[0]
$validFirstLetter = $firstLetter -match '[A-Za-z]'
if(-not $badChar -and $username.Length -le 20 -and $validFirstLetter ){
Write-Host("$username is valid");
}else{
Write-Host("$username is Invalid");
}
}