Remove leading digits from a string

后端 未结 2 1369
盖世英雄少女心
盖世英雄少女心 2021-01-25 16:47

How can I remove all the digits from the start of a string.

Before:

234234adsf3fs3fs34

After:

adsf3fs3fs34
2条回答
  •  别那么骄傲
    2021-01-25 17:18

    You can use -Replace, which does accept RegEx:

    "234234adsf3fs3fs34" -replace "^[0-9]*"
    

    That will result in your desired output.

    Alternatively you can use the .TrimStart() method as such:

    ("234234adsf3fs3fs34").TrimStart("0123456789")
    

    That will also output what you want. It looks for anything contained within the () to remove, but is not RegEx friendly.

提交回复
热议问题