Get only numbers from string

前端 未结 8 598
耶瑟儿~
耶瑟儿~ 2021-01-01 15:37

i want to get only numbers from string.

Lest say that this is my string :

324ghgj123

i want to get:

324123
8条回答
  •  一个人的身影
    2021-01-01 15:57

    You can actually combine some of these individual answers to create a single line solution that will either return an integer with the value 0, or an integer that is the concatenation of all of the numbers in the string. Not sure how useful that is, however -- this began as a method to create a string of numbers only....

        Dim TestMe = CInt(Val(New Text.StringBuilder((From ch In "123abc123".ToCharArray Where IsNumeric(ch)).ToArray).ToString))
    

提交回复
热议问题