gpt4 book ai didi

c# - 如何插入软连字符

转载 作者:太空宇宙 更新时间:2023-11-03 17:18:11 25 4
gpt4 key购买 nike

我想使用 powershell 在单词的每个字母之间插入一个软连字符。例如这里是一些文本:

Thisisatest => T-h-i-s-i-s-a-t-e-s-t

- 是软连字符。我如何在 powershell 中执行此操作?

最佳答案

使用比规范 PowerShell 代码多一点的 .NET 方法,您可以编写

$word = "Thisisatest"
[System.String]::Join("-", $word.ToCharArray())

Powershell 输出“T-h-i-s-i-s-a-t-e-s-t”

编辑:对于真正的软连字符,并使用 this answer on Unicode in PowerShell , 我会将第二行更改为

[System.String]::Join([char] 0x00AD, $word.ToCharArray())

关于c# - 如何插入软连字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9165664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com