【问题标题】:How to extract number from string如何从字符串中提取数字
【发布时间】:2013-07-18 09:43:06
【问题描述】:

我的数组包含这样的字符串:

eth1
eth12
eth20
eth35
eth5

我想要另一个只包含这些字符串数量的数组:

1
12
20
35
5

我尝试了 Trimend() 函数,但我不知道如何指定这个...

感谢您的帮助

【问题讨论】:

  • 也许您可以使用Replace("eth", "") 函数?

标签: arrays string powershell powershell-3.0


【解决方案1】:

这是一种方式

$mynewarray = $myarray  -replace 'eth' 

如果文本不总是'eth'

$mynewarray = $myarray -replace '\D' 

【讨论】:

    猜你喜欢
    • 2019-06-03
    • 2016-11-05
    • 2012-03-03
    • 2020-11-20
    • 2021-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多