Guest User

Untitled

a guest
Nov 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. $answer = read-host
  2. $answer.replace(' ' , '""')
  3.  
  4. $answer = read-host
  5. $answer -replace (' ')
  6.  
  7. $string = $string -replace 's',''
  8.  
  9. $string = $string -replace '(^s+|s+$)','' -replace 's+',' '
  10.  
  11. $string = $string.Trim()
  12.  
  13. '2033' -replace '(d+)',$( 'Data: $1')
  14. Data: 2033
  15.  
  16. #Note there are spaces at the beginning and end
  17. Write-Host " ! This is a test string !%^ "
  18. ! This is a test string !%^
  19. #Strips standard whitespace
  20. Write-Host " ! This is a test string !%^ ".Trim()
  21. ! This is a test string !%^
  22. #Strips the characters I specified
  23. Write-Host " ! This is a test string !%^ ".Trim('!',' ')
  24. This is a test string !%^
  25. #Now removing ^ as well
  26. Write-Host " ! This is a test string !%^ ".Trim('!',' ','^')
  27. This is a test string !%
  28. Write-Host " ! This is a test string !%^ ".Trim('!',' ','^','%')
  29. This is a test string
  30. #Powershell even casts strings to character arrays for you
  31. Write-Host " ! This is a test string !%^ ".Trim('! ^%')
  32. This is a test string
  33.  
  34. $answer.replace(' ' , '')
  35.  
  36. $answer -replace " ", ""
  37.  
  38. $answer -replace "s", ""
Add Comment
Please, Sign In to add comment