0

Kindly help me know the regex to select only span id for a given span markup. I'm trying to do it from inside c#. My input is like . And I want as an output only >> id="x8x8d9s8" <<

Currently I'm trying to achieve above as follows but no luck, unfortunately ...

string innerPattern = @"(id=)\""|&quot;|(.)*\""|&quot;|";

Please note its only the start span tag, I do not want to include end span tag i.e.

Any help would be greatly appreciated.

Thanks in advance.

user383698
  • 85
  • 1
  • 3
  • 16
  • 3
    [Here's a helpful answer that details how to parse HTML using regex](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) –  Aug 27 '10 at 13:32
  • Just another one of 100000 questions how to parse HTML with RegEx. Please try to search a bit.. – abatishchev Aug 27 '10 at 13:33
  • Thank you buddy ! I apologies I fired my question right away without any much research. But it was bit urgent. Thanks for the link anyways. I'm going to bookmark that. Will surely help newbie like me to understand regex. Thanks. – user383698 Aug 27 '10 at 14:01

1 Answers1

2

What about this :

(id=".*?")

In C# :

@"(id="".*?"")"

Tried on this regex tester with tagada <span id="test" tagada />

Colin Hebert
  • 91,525
  • 15
  • 160
  • 151