• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

luchen-mj

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

powershell随笔

目录
  • powershell随笔
    • 字符串相关函数
      • -match
      • -replace
      • 格式化操作
    • 子表达式
    • 资源网站

powershell随笔

忘记时来看。。。

字符串相关函数

-match

#Format   [value]
#Logic    Matches at least one of the characters in the brackets.
"big" -match "b[iou]g"

Powershell - Regular Expression - Match Characters | Tutorialspoint

-replace

"one, two, three, four" -replace ","
# the answer is:
# one two three four

PowerShell替换字符串(-replace操作符) - PowerShell - 洪哥笔记 (splaybow.com)

格式化操作

"the location is {0}, the time is {1}" -f $(Get-Location), $(Get-Date)
# the location is D:\code\shell, the time is 2023/7/22 18:54:21

$a = get-location
"the location is $a"
# the location is D:\code\shell

powershell字符串操作 - 一个有故事的devops - 博客园 (cnblogs.com)

子表达式

$a = $(get-location)
$a
# Path
# ----
# D:\code\shell

$()返回子表达式的结果,可以在一些字符串中使用,例如:the location is $(get-location)

资源网站

  • Powershell Tutorial | Tutorialspoint

posted on 2023-07-22 19:11  rockma  阅读(23)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3