0

This is my HTML tag as string

<span class="version">Version: DEV</span>

Now I would like to read version "DEV" back with regex

I try with:

 Regex regex = new Regex("\"version\">Version:\\s*([^\\s<]+)\\s*</");
 Match match = regex.Match(data);

but regex is always False and I don't get data back

Aslam Jiffry
  • 1,306
  • 6
  • 23
  • 57
senzacionale
  • 20,448
  • 67
  • 204
  • 316

1 Answers1

1

I believe you have an extra < in your capture ([^\\s<]+). If you want to capture word characters, I find it easier to use \w versus negating whitespace [^\s]+.

Expression alone, no escapes:

"version">Version:\s*(\w+)\s*</span>

C#:

Regex regex = new Regex("\"version\">Version:\\s*(\\w+)\\s*</span>");
Corbin March
  • 25,526
  • 6
  • 73
  • 100