-2

[code]> 10 /td>[/code]

I want to get 10 from this line. But I need to preserve the pattern. How can I write an expression that gets:

, newline, ignorewhitespace OR included indeterminate spaces, 10, ignorewhitespace OR included all space, /td

Thanks, JOe K.

tjcinnamon
  • 345
  • 2
  • 7
  • 20

1 Answers1

0

Ok, I'll be nice and help you this time. =)

I assumed that the number you are looking for can change.

var result = Regex.Match(
      "[code]>   101   /td>[/code]",
      @"(?<=\>\s*)\d+(?=\s*/td\>)").Value;

But please, try doing it the next time... I'll point you a tool that could help in designing and learning Regex:

http://www.radsoftware.com.au/regexdesigner/

Miguel Angelo
  • 23,796
  • 16
  • 59
  • 82
  • I did try with some tools. But I appreciate your contribution. Pierre-Luc Pinault also had a good suggestion in not using regex for HTML. Thanks to everyone! – tjcinnamon Jul 23 '13 at 18:55
  • Yes, most of the time, you shouldn't be using regex with html... but sometimes, it is needed, maybe because you are in a hurry, or when what you need from the html is something so simple, that it is easier to use a regex. I have already worked with html crawlers that extracted information from it, and I can say for sure that: 80% of html parser for 20% of regex is a great ratio. – Miguel Angelo Jul 23 '13 at 18:59
  • Also try [Regexr](http://gskinner.com/RegExr/) as a quick way to test Regex when designing them – dav_i Jul 23 '13 at 21:03