Advertisement

05.06.2007 at 09:46PM PDT, ID: 22556012
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.2

Greedy Regex has me bugged

Asked by sapbucket in C# Programming Language, Perl Programming Language, Regular Expressions

Tags: , ,

[a|A] [h|H][r|R][e|E][f|F]["|=]["|=]?(\w+?\.mpg|\w+?\.wmv)
[a|A] [h|H][r|R][e|E][f|F]["|=]["|=]?[\.\./]?(\w+?\.mpg|\w+?\.wmv)

I am using a regex string to parse html files. There are several variations (strategies) I want to parse. I want to combine them in to one string.

string myRegex = "[a|A] [h|H][r|R][e|E][f|F]["|=]["|=][\.]?[\.]?[/]?(.+\.xls|.+\.dat)";

The goal is to parse every ".xls" and ".dat" file from html.

My test data:

<BODY BGCOLOR="000033" TOPMARGIN="0">
<DIV ALIGN="CENTER"><TABLE WIDTH="805" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD HEIGHT="41" BGCOLOR="000033"><IMG SRC="images/top-header2.jpg" WIDTH="805" HEIGHT="300" USEMAP="#Map" BORDER="0"><MAP NAME="Map"><AREA SHAPE="rect" COORDS="321,6,500,108" HREF="http://www.elli.com/track/MzoxNTox/"></MAP></TD></TR><TR><TD HEIGHT="2" BGCOLOR="000033"><A HREF="http://join.elli.com/track/MzoxNTox/"><IMG SRC="images/top3.jpg" WIDTH="805" HEIGHT="37" BORDER="0"></A></TD></TR><TR><TD HEIGHT="416" BGCOLOR="#660066"><TABLE WIDTH="805" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#660066"><TR><TD HEIGHT="241"><DIV ALIGN="CENTER"><A HREF="budget01.xls"><IMG SRC="p1.jpg" WIDTH="400" HEIGHT="300" border="0"></A></DIV></TD><TD HEIGHT="241"><DIV ALIGN="CENTER"><A HREF="budget02.xls"><IMG SRC="p2.jpg" WIDTH="400" HEIGHT="300" border="0"></A></DIV></TD></TR><TR><TD HEIGHT="38"><DIV ALIGN="CENTER"><FONT FACE="Tahoma" SIZE="4"><B><FONT COLOR="#66CC00"

Should output:
matches[0].Groups[1] == "budget01.xls"
matches[1].Groups[1] == "budget02.xls"

But instead outputs:
matches[0].Groups[1]  == "http://join.elli.com/track/MzoxNTox/"><IMG SRC="images/top3.jpg" WIDTH="805" HEIGHT="37" BORDER="0"></A></TD></TR><TR><TD HEIGHT="416" BGCOLOR="#660066"><TABLE WIDTH="805" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#660066"><TR><TD HEIGHT="241"><DIV ALIGN="CENTER"><A HREF="budget01.xls"><IMG SRC="p1.jpg" WIDTH="400" HEIGHT="300" border="0"></A></DIV></TD><TD HEIGHT="241"><DIV ALIGN="CENTER"><A HREF="budget02.xls"

Why does the regex include too much? I do not understand how to control the "greediness".

I have been struggling to understand how I can correct this. An experts suggestion would be greatly appreciated.

Start Free Trial
 
 
[+][-]05.06.2007 at 10:32PM PDT, ID: 19041135

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.07.2007 at 02:32AM PDT, ID: 19041705

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.07.2007 at 04:54AM PDT, ID: 19042053

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.07.2007 at 05:47AM PDT, ID: 19042302

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Perl Programming Language, Regular Expressions
Tags: parse, regex, greedy
Sign Up Now!
Solution Provided By: mjcoyne
Participating Experts: 5
Solution Grade: A
 
 
[+][-]05.08.2007 at 02:22AM PDT, ID: 19048460

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2007 at 11:11PM PDT, ID: 19113728

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2007 at 09:51AM PDT, ID: 19226636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.29.2007 at 05:15PM PDT, ID: 19394365

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.03.2007 at 03:32PM PDT, ID: 19415284

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.03.2007 at 07:21PM PDT, ID: 19416191

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.03.2007 at 10:27PM PDT, ID: 19416658

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.04.2007 at 04:51AM PDT, ID: 19417944

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.08.2007 at 06:00PM PDT, ID: 19442204

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.21.2007 at 06:56AM PDT, ID: 19538939

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.21.2007 at 07:07AM PDT, ID: 19539062

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.29.2007 at 08:09AM PDT, ID: 19588244

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44