找回密码
 注册

QQ登录

只需一步,快速开始

查看: 485|回复: 0

String Functions in PowerShell

[复制链接]
发表于 2011-11-22 09:54:29 | 显示全部楼层 |阅读模式
PowerShell uses .NET objects everywhere. Anything is represented as .NET object, and .NET objects come with useful built-in methods. However, for string manipulation you do not need to look for sophisticated external commands as they are built right into strings.
Here are a couple of useful examples:
  1. "Hello".ToLower()
  2. "Hello".ToUpper()
  3. "Hello".EndsWith('lo')
  4. "Hello".StartsWith('he')
  5. "Hello".toLower().StartsWith('he')
  6. "Hello".Contains('l')
  7. "Hello".LastIndexOf('l')
  8. "Hello".IndexOf('l')
  9. "Hello".Substring(3)
  10. "Hello".Substring(3,1)
  11. "Hello".Insert(3, "INSERTED")
  12. "Hello".Length
  13. "Hello".Replace('l', 'x')
  14. "Server1,Server2,Server3".Split(',')
  15. " remove space at ends ".Trim()
  16. " remove space at ends ".Trim(' rem')
复制代码




http://powershell.com/cs/blogs/tips/archive/2009/06/08/using-string-functions.aspx
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-6-11 14:16 , Processed in 0.013335 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表