Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Rex match

Posted on 2011-10-12
Medium Priority
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 75

Expert Comment

by:käµfm³d 👽
ID: 36955160
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.

Expert Comment

ID: 36955174

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

mgfranz earned 2000 total points
ID: 36956383
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


Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

569 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