Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 681175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:27:17+00:00 2026-05-14T01:27:17+00:00

using System; using System.IO; using System.Net; using System.Text.RegularExpressions; namespace Working { class Program4 {

  • 0
using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;

namespace Working
{
    class Program4
    {
        static string errorurl = 
               "http://www.realtor.ca/propertyDetails.aspx?propertyId=8692663";

        static void Main(string[] args)
        {
            string s;

            s = getWebpageContent(errorurl);

            s = removeNewLineCharacters(s);

            getFields(s);

            Console.WriteLine("End");
        }


        public static void getFields(string html)
        {
            Match m;
            string fsRE = @"ismeasurement.*?>.*?(\d+).*?sqft";
            m = Regex.Match(html, fsRE, RegexOptions.IgnoreCase);
        }

        private static string removeNewLineCharacters(string str)
        {
            string[] charsToRemove = new string[] { "\n", "\r" };

            foreach (string c in charsToRemove)
            {
                str = str.Replace(c, "");
            }

            return str;
        }


        static string getWebpageContent(string url)
        {
            WebClient client = new WebClient();

            client.Headers.Add("user-agent",
            "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; 
                          .NET CLR 1.0.3705;)");

            Stream data = client.OpenRead(url);
            StreamReader reader = new StreamReader(data);
            string s = reader.ReadToEnd();
            data.Close();
            reader.Close();

            return s;
        }
    }
}

This program hangs. It runs correctly when I remove RegexOptions.IgnoreCase option or
when I remove call to removeNewLineCharacters() function.
Could someone tell me what is going on, please?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:27:17+00:00Added an answer on May 14, 2026 at 1:27 am
    @"ismeasurement.*?>.*?(\d+).*?sqft"
    

    Seeing so many lazy matches, I guess too much time is spent on backtracking.

    Try to refactor it into not using lazy matches, e.g.

    @"ismeasurement[^>]*>\D*(\d+)\s*sqft"
    

    The reason removing RegexOptions.IgnoreCase works is because there is only the string “isMeasurement” in that page. The reason removing removeNewLineCharacters works is because . doesn’t match new lines so it can stop early.

    (BTW, why are you matching HTML with Regex?)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using System; using System.Linq; using System.Text; using System.Net; using System.IO; namespace LearningJustCode { class
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using HtmlAgilityPack; namespace sss
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Mail; using Microsoft.Exchange.WebServices.Data; namespace Email
I am trying to check a valid Regex expression, with this class: using System.Text.RegularExpressions;
using System; using System.ComponentModel; using System.Net; using System.Windows.Forms; using Ionic.Zip; namespace downloader { public
using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.IO; using System.Net; using System.Net.Mail;
Our application is sending our emails with Word attachments using System.Net.Mail. We have empty-string
ok ive got this code: public static string ScreenScrape(string url) { System.Net.WebRequest request =
I am using this code for sending email in asp.net: Using System.Net.Mail public string
I'm basically running the example here: http://msdn.microsoft.com/en-us/library/system.net.httplistener.begingetcontext.aspx using System; using System.Collections.Generic; using System.Linq; using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.