Take a string snippet

Asked

Viewed 156 times

0

I want to take the word "[email protected]" that’s inside that metromessagebox

I tried that, but it didn’t work out:

String[] palavra = ex.Message.Split(new String[] { "(", ")" }, StringSplitOptions.RemoveEmptyEntries);

inserir a descrição da imagem aqui

  • I can’t understand what you want to do. Want to get the last information in the message box or you have the text and want to see if it is contained in the message?

  • If you want to get the text of the message, probably you will have to use REGEX in what generates this message ai, is always this way?

  • people, is that type oq appears in the mesagebox is a string, I want to get what is between parentheses in this string, this messagebox I am treating the error and I do not want to appear that, I just want to appear the name of the field that the user placed.

  • And if there’s anything else in parentheses?

  • remembering what is between parentheses and a word varied, always changes....

1 answer

0

There is no mystery, just capture the text inside the parentheses.

Regex

var s = Regex.Match(ex.Message, @"\(([^)]*)\)").Groups[1].Value;

Regex-free

string output = ex.Message.Split('(', ')')[1];

See working on . NET Fiddle

Browser other questions tagged

You are not signed in. Login or sign up in order to post.