Jump to content

Recommended Posts

Posted

Olá mais uma vez.

Estou com um problema.

Por necessidade ando a investigar a função Regex, mas não estou a conseguir filtrar isto:

<meta name="description" content="Amazon.com: Louden Up Now: !!!: Music" />

Objetivo:

Filtrar em 1 textbox apenas o texto: "Louden Up Now: !!!".

Objetivo 2 (ainda não tentei fazer, pois não consigo o 1)

Em 1 textbox colocar o valor: "Louden Up Now" e em outra "!!!"

Cumpz.

Posted

Podes tentar assim:

var str = "<meta name=\"description\" content=\"Amazon.com: Louden Up Now: !!!: Music\" />";
var result = System.Text.RegularExpressions.Regex.Match(str, @"\[^:]*)\:");

if (result.Groups.Count != 0 )
{
  MessageBox.Show(result.Groups[1].Value);
  // Resultado: Louden Up Now
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.