Rex match

Posted on 2011-10-12
Last Modified: 2012-05-12
hey guys i have this rex matcher

// ### Grab the <TITLE> ###
 Match TitleMatch = Regex.Match(fileContents, "<title>([^<]*)</title>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
filetitle = TitleMatch.Groups[1].Value;

i need to grab my aspx title

which is

Title="JC Web Internet Services | Your local trusted Durban ISP"

can any one help me so i can change my rex to find my new title text?
Question by:JCWEBHOST
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Is you pattern not working? It looks like you are inspecting the first capture group correctly, which is where the text of your title should be.
    LVL 3

    Expert Comment


    try this (it's C#).

                string test = "<html><title>JC Web Internet Services | Your local trusted Durban ISP</title></html>";

                Regex ex = new Regex("(<title>)(.*)(</title>)");
                Match m = ex.Match(test);
                if (m.Groups.Count > 2)
                    Console.WriteLine("Title is: {0}", m.Groups[2]);
                    Console.WriteLine("Sorry, didn't get it");

    LVL 18

    Accepted Solution

    Try this;
    // subjectString = "<title>JC Web Internet Services | Your local trusted Durban ISP</title>;
    string resultString = null;
    try {
    	Regex regexObj = new Regex(@"<title[^>]*>(.*?)</title>
    	resultString = regexObj.Match(subjectString).Value;
    } catch (ArgumentException ex) {
    	// Syntax error in the regular expression

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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

    Suggested Solutions

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    760 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

    15 Experts available now in Live!

    Get 1:1 Help Now