user383698
user383698

Reputation: 85

Regex to select span ID

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.

Upvotes: 0

Views: 892

Answers (1)

Colin Hebert
Colin Hebert

Reputation: 93177

What about this :

(id=".*?")

In C# :

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

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

Upvotes: 2

Related Questions