Regex to check if string has special characters except dash and comma and split

If string contains special character like hello-world but not dash(/) and comma (,) then split get the string output which is

input: hello-world
output : world

input : hi,hello
output: hi,hello

input : my-friend
output: friend

Thanks

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Match(text,"[/,A-Za-z0-9]+$").Value

Regards,

1 Like

Hi @Jelrey

Use regular expression

(?=world).* Use ismatch activity or matches

Thanks
Ashwin.S

1 Like

For special characters you can use \S in regular expression

1 Like

grafik

I wanted to add Sir that if its a string like 3 words seperated by a space like “I am hello”

it should output I am hello and should not cut it . It should only get the second word if it has special character match else get the original string.

input: hello-world
output : world

input : hi,hello
output: hi,hello

input : my-friend
output: friend

input : hello
output: hello

input : my name is
output : my name is

Hi,

How about the following?

System.Text.RegularExpressions.Regex.Match(text,"[ /,A-Za-z0-9]+$").Value

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.