Regex to Check String More Than Two Words Only Contains Alpabet

Hi Everyone,

I have a problem like in the title.

example:

  • “Agus Suparman” >> bool result true

  • “Agus @Suparman” >> bool result false

  • “Agus’ Suparman” >> bool result false

  • “A. Suparman” >> bool result false

I want to check if the string only contains alphabet and ‘space’.
No numbers and all special characters.

Thanks in advance

@JodhyPutra Can you try this Expression :
boolVar = str.All(Function(x)char.isLetter(x) or x = " ")

Where str is the String you need to Check. This Expression will return a boolean value, True if Only letters or a space is present else False.

2 Likes

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.IsMatch(yourString,"^[ A-Za-z]*$")

Regards,

3 Likes

Where I use that? is it assign activity?

Hello @Yoichi :slight_smile:
you could try this also to get a bool you can use it in an if condition
System.Text.RegularExpressions.Regex.Match(StringText,"^[ A-Za-z]*$").Success

2 Likes

Hi,

Yes, you can use it in assign activity as the following.

isOnlyAlphabet  = System.Text.RegularExpressions.Regex.IsMatch(yourString,"^[ A-Za-z]*$")

or you can directly set the expression in condition property of if activity.

Regards,

1 Like

@Yoichi & @Lwissitoon
can you tell me ^, *, $
what is it used for?

Hi,

Hope the following link helps you.

Regards,

1 Like