Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Extract text using regex

Hi

I have the following text in a file:

("profile/happ1","profile")]

Open in new window


How can I extract just "happ1" from this using c#?

thanks
0
zattz
Asked:
zattz
1 Solution
 
zattzAuthor Commented:
public static string extractFrom(string html)
        {
            string anchor = "('profile/";
            int startIndex = html.IndexOf(anchor) + anchor.Length;
            int endIndex = html.IndexOf("?", startIndex);
            string txt = html.Substring(startIndex, endIndex - startIndex);
            return txt;
        }
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now