0

I have some HTML code:

<div class="code">
<span class="title">desc</span>:<span class="value">'Custom text'</span>,

<div class="code">
    <span class="title">
    </span>
<div>

I need to get the content between <span class="value">...</div> tags. I tried to get - Custom text. How can I do it with Regex and C#?

3
  • Do you want to get only 'Custom text' or the values between every tag? Commented Nov 27, 2015 at 7:03
  • use regex as "<span class="value">(.|\n)*?</span>" and from result data replace tags and get your answer Commented Nov 27, 2015 at 7:05
  • Are you sure, you meant "</div>"? Your openening tag is span... Commented Dec 2, 2015 at 8:33

3 Answers 3

1

You can capture in first group like:

<span .*? class="value".*?>([^<]+)<\/span>
Sign up to request clarification or add additional context in comments.

Comments

0

You can use the following regex:

<span[^>]*class=\"value\"[^>]*>([^<]*)<\/span>

Comments

0

Add runat="server" to the control of which you want to extract the data in your CS page

HTML:

<span class="value" id="test" runat="server">'Custom text'</span>

CS

String vl=test.InnerHtml;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.