Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $answer = read-host
- $answer.replace(' ' , '""')
- $answer = read-host
- $answer -replace (' ')
- $string = $string -replace 's',''
- $string = $string -replace '(^s+|s+$)','' -replace 's+',' '
- $string = $string.Trim()
- '2033' -replace '(d+)',$( 'Data: $1')
- Data: 2033
- #Note there are spaces at the beginning and end
- Write-Host " ! This is a test string !%^ "
- ! This is a test string !%^
- #Strips standard whitespace
- Write-Host " ! This is a test string !%^ ".Trim()
- ! This is a test string !%^
- #Strips the characters I specified
- Write-Host " ! This is a test string !%^ ".Trim('!',' ')
- This is a test string !%^
- #Now removing ^ as well
- Write-Host " ! This is a test string !%^ ".Trim('!',' ','^')
- This is a test string !%
- Write-Host " ! This is a test string !%^ ".Trim('!',' ','^','%')
- This is a test string
- #Powershell even casts strings to character arrays for you
- Write-Host " ! This is a test string !%^ ".Trim('! ^%')
- This is a test string
- $answer.replace(' ' , '')
- $answer -replace " ", ""
- $answer -replace "s", ""
Add Comment
Please, Sign In to add comment