Link to home
Start Free TrialLog in
Avatar of JCWEBHOST
JCWEBHOST

asked on

Rex match

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?
Avatar of kaufmed
kaufmed
Flag of United States of America image

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.
Avatar of KBerger
KBerger

Hi,

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]);
            }
            else
            {
                Console.WriteLine("Sorry, didn't get it");
            }
            Console.ReadLine();

Cheers,
-Kristof
ASKER CERTIFIED SOLUTION
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial