Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Extract text using regex

Posted on 2013-02-06
1
Medium Priority
?
324 Views
Last Modified: 2013-02-06
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
Comment
Question by:zattz
1 Comment
 

Accepted Solution

by:
zattz earned 0 total points
ID: 38859766
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question