powershell - Powershell 装饰线
问题描述
我有以下字符串:
Account name: abc.def
例如,其中 abc.def 是用户名John.doe
。
我需要修剪这个字符串,只留下用户名,例如abc.def
无论我尝试什么select-string
或-match
没有让我到达那里。
解决方案
您可以删除直到并包括:
with的所有内容-replace
,然后让我们String.Trim()
处理空格:
PS ~> $string = "Account name: abc.def"
PS ~> ($string -replace '^.*?:').Trim()
abc.def
推荐阅读
- java - 不兼容的类型会返回 statictype 的泛型方法
- windows - 如何在 Windows 上的 git 中使文件可读可写?
- android - 我可以在 /libs 文件夹中发布包含另一个 AAR 文件的 AAR 文件吗?
- spring - Spring boot app gracefully catch the SIGTERM signal and invoke the predestroy method
- http - How to avoid Uri encoding using Uri.https from Dart library
- javascript - How would I configure my webpack.config.js file to properly navigate to other html pages?
- python - 拆分具有特定后缀的数据帧
- c++ - OpenGL 4.6 Game Program - Water Reflection - Flicker Problem
- android - 为什么我的警报对话框在第二次出现时使我的应用程序崩溃?
- database - PL/SQL函数如何显示加薪和加薪10000以上的工资