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

  • SEARCH
  • Home
  • 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 7054235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:36:07+00:00 2026-05-28T03:36:07+00:00

I’m struggling for over a day with what I’d though would be an easy

  • 0

I’m struggling for over a day with what I’d though would be an easy thing.

I need to parse a page’s HTML to find some structured data.

Here’s the test string:

<option value="0794">0794 - SANTA MARIA</option>
<option value="0795">0795 - ALICE COUTINHO</option>
<option value="0800">0800 - T.LARANJEIRAS (CIRCULAR A E B) - VIA T. CARAPINA/J. CAMBURI</option>
<option value="0801">0801 - T. LARANJEIRAS / T. CARAPINA - VIA VALPARAISO / J. LIMOEIRO</option>
<option value="0802">0802 - DIVINOPOLIS / T.LARANJEIRAS VIA CENTRO DA SERRA</option>

And here’s the Regex pattern:

^\s+<option value="\d+">(?<linha>\d+) - (?<nome>(.*?))</option>$

When debugging with Visual Studio 2010 it find no matches.

Full code:

var pattern = @"^\s+<option value=""\d+"">(?<linha>\d+) - (?<nome>(.*?))</option>$";
var regex = new Regex(pattern, RegexOptions.Multiline);
var matches = regex.Matches(html)

html is the test string and matches.Count is always 0.

I’ve already tested on http://regexhero.net/tester/ and on http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx and it works perfectly.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 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-28T03:36:08+00:00Added an answer on May 28, 2026 at 3:36 am

    I see two problems. First, there’s the ^\s+ at the beginning of the regex. In Multiline mode, ^ matches the position following a linefeed. \s+ matches one or more whitespace characters. But there aren’t any whitespace characters after the linefeeds. If you think there might be space or tab characters at the beginning of the line, you should change the + to *; otherwise, just drop the \s+.

    Second, the regex ends with $, which matches just before a linefeed. But when I copied the text from your post, the lines ended with \r\n (carriage-return + linefeed), and you aren’t accounting for the \r.

    When I change the ^\s+ to ^ and the $ to \r?$, I get five matches. By the way, the second problem is .NET’s fault, not yours; $ in multiline mode should match before \r, as detailed here.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.