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?
// ### 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?
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.
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>)(.*)(</tit le>)");
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
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>)(.*)(</tit
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.