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?
JCWEBHOSTAsked:
Who is Participating?
 
mgfranzCommented:
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

0
 
käµfm³d 👽Commented:
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.
0
 
KBergerCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.