How to check if a string has any letter?

Hi,

I have such strings : A120, 1020, XD39 etc. I need only these with numbers. How to do this? With Regex?

Hi @Marek_Matuszak

Do u mean u need to check whether any string contains letter then use this

Yes I mean this

use this

Regex.Match(yourInputString, “\d+(?:[.,]\d+)*”)

hope it will work

Try this

[A-Z]+[0-9]+ @Marek_Matuszak

to be honest I mean more like remove these letters from this string and have only numbers

I thought you want to check if it contains number etc…

Anyhow use this.

System.Text.RegularExpressions.Regex.Replace(“string_Variable”,"\D","")

Hope it will work

hmm Text is not a member of string

System.Text.RegularExpressions.Regex.Replace(“string_Variable”,"\D","")

Hope it will work
I have updated the regex.

no idea why it doesnt work :frowning: text is not a member of string and it doesnt compile

Did u try with the regex pattern I told ?

It is working for me…

image

System.Text.RegularExpressions.Regex.Replace(StringVar,"\D","")

Output
image