Solved

Extract text using regex

Posted on 2013-02-06
1
315 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now