-1

I have a string similar to this, this string is from a long HTML page source:

"entity_id":"1234567890"

I'm trying to parse the number 1234567890 like this, but the id could not be parsed:

var re = new Regex("\"entity_id\":\"([0 - 9] +)\"");
var match = re.Match(task.Result);

var id = match.Success ? match.Value : string.Empty;
Console.WriteLine(id);

Why it it's not parsed and how to fix it?

double-beep
  • 5,031
  • 17
  • 33
  • 41
ivy104902
  • 3
  • 2

1 Answers1

1

Lose the spaces:

//var re = new Regex("\"entity_id\":\"([0 - 9] +)\"");
  var re = new Regex("\"entity_id\":\"([0-9]+)\"");

and then use

 var id = match.Success ? match.Groups[1].Value : string.Empty;
H H
  • 263,252
  • 30
  • 330
  • 514