Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 18th, 2012, 09:23 AM
matos240 matos240 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 33 matos240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 14 m 2 sec
Reputation Power: 10
Exression Help

Hello everyone I'm super new to Regular Expressions. I need an expression that will pickout the text from the paragraphs in html markup like the snippet shown below. I would pay someone through paypal or vworker but I don't have a cent right now and super duper need this to get a tutorial to work. I need this for a job interview that I'm going to attend tommorow Thursday. I promise to pay you when I have money in my paypal account on May 7th if that's what it takes. And if that's what it takes then let me know how much you would require. You can email me at juan.matos@juanmatos.net here's the snippet:
Code:
<p class="row">
			<span class="ih" id="images:5N25Gf5F13Ga3M23Ffc3u3b475684d2051dd4.jpg">&nbsp;</span>
			 Apr 18 - <a href="http://miami.craigslist.org/mdc/cto/2912842874.html">96 bronco must sale stong truck -</a>
			 $2600<font size="-1"> (homestead)</font> <small class="gc"><a href="/cto/">owner</a></small> <span class="p"> pic</span><br class="c">
		</p>
		<p class="row">
			<span class="ih" id="images:5Ia5K85H13I43Jc3Hcc4ae516ae209bf414f3.jpg">&nbsp;</span>
			 Apr 18 - <a href="http://miami.craigslist.org/brw/cto/2951611980.html">Ford F250 Diesel Truck  -</a>
			 $3500<font size="-1"> (pompano beach)</font> <small class="gc"><a href="/cto/">owner</a></small> <span class="p"> pic</span><br class="c">
		</p>
		<p class="row">
			<span class="ih" id="images:5Hf5X45J63F23I83N2c4iec514f9df8b61810.jpg">&nbsp;</span>
			 Apr 18 - <a href="http://miami.craigslist.org/mdc/cto/2964917755.html">BLUE TRUCK FORD F150 -</a>
			 $2149<font size="-1"> (MIAMI (CUTLERBAY))</font> <small class="gc"><a href="/cto/">owner</a></small> <span class="p"> pic&nbsp;img</span><br class="c">
		</p>

Reply With Quote
  #2  
Old April 18th, 2012, 09:29 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,711 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 48 m 5 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
So you want to pay somebody to answer a question that a potential employer asked you specifically?

Reply With Quote
  #3  
Old April 18th, 2012, 09:52 AM
matos240 matos240 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 33 matos240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 14 m 2 sec
Reputation Power: 10
It would be so refreshing to see a decline in replies from ppl on forums who come across as stupid. To read into my original post and come to assume that the interview has to do my ability to write a regular exrpession makes me wonder how such a person even gets through the day without accidently stepping off the curb in front of a speeding car. The tutorial is about A, B, C and D. My responsibilty at the job should i get it has to do with A and B. The Regular Expression in the tutorial which is outdate would be the "C" part. And that part is not necessary for me to know for to do my job. But that "C" part is needed to get the whole program to function. So that as a whole I can understand what I need to know. I have a friendwho always assumes that a car slowing down to make a right hand turn is going to make the right hand turn when the care has slowed down to about 10 mph right at the turn. But sometimes the driver that is showing that he is going to turn just suddenly stops. My friend will hit this guy 9 out of 10 times. He always makes the assumtion that that car is going to turn. He's STUPID as far as I'm concerned.

Reply With Quote
  #4  
Old April 18th, 2012, 10:09 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,711 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 48 m 5 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
A simple "no" would have sufficed. I'd rather not have to break down my response into the individual components of your post that I was directing it at. But I will say
Quote:
Originally Posted by matos240
I have a friendwho always assumes that a car slowing down to make a right hand turn is going to make the right hand turn when the care has slowed down to about 10 mph right at the turn. But sometimes the driver that is showing that he is going to turn just suddenly stops. My friend will hit this guy 9 out of 10 times. He always makes the assumtion that that car is going to turn. He's STUPID as far as I'm concerned.

Glad I'm not your friend then.


Regex isn't the best choice for dealing with HTML. Does it have to be a regex?

Last edited by requinix : April 18th, 2012 at 10:11 AM.

Reply With Quote
  #5  
Old April 18th, 2012, 10:21 AM
matos240 matos240 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 33 matos240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 14 m 2 sec
Reputation Power: 10
I'm sorry I went off. But I took that remark as an indication that what I was doing as unethical, shady, mis-honest...And I don't take well to that kind of poking. That is one of my character flaws I guess. But to answer your question yes because most of the code is written around this assumption.

Reply With Quote
  #6  
Old April 18th, 2012, 11:53 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,711 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 48 m 5 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
You have to admit that things like "I need this for a job interview" sound a certain way...


Well at least the HTML looks very uniform. When I write regular expressions for things like this I prefer to be very specific and use as few wildcards as possible, so
Code:
<p class="row">\s+
<span class="ih" id="images:[a-z0-9]+.jpg">&nbsp;</span>\s+
(... ..) - <a href="http://miami.craigslist.org/[a-z]+/cto/\d+.html">(.*?) -</a>\s+
(\$\d+)<font size="-1"> (.*?)</font> <small class="gc"><a href="/cto/">owner</a></small> <span class="p">.*?</span><br class="c">\s+
</p>

- I left it spanning multiple lines for the sake of reading it in this post. You'll probably want to collapse it all into one line
- You can throw in a few more capturing groups for things like links or images if you want
- Also feel free to substitute out some of the HTML for .*?s
- If you have to wrap delimiters around it, don't forget to escape any inside the expression (like the few slashes in there)

Reply With Quote
  #7  
Old April 18th, 2012, 02:01 PM
matos240 matos240 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 33 matos240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 14 m 2 sec
Reputation Power: 10
I tried your expression but it has lots that isn't liked by the compiler. I tried playing around for it but for now this is beyond my capabilities. But super duper thanks for what you have done so far and I belive i have avoided the Regular Expression learning long enough and it's time to learn it. Folks the expression from the tutorial is this one.

string expression = @"<p>[^<]*<a[^>]*>(?<item>[^<]*)</a>";

But it seems that the Craigslist format is different now. This tutorial posting is 3 years ago. So it doesn't work anymore. I provide the expression so that it may give an idea of how to go about this. Super please....

Reply With Quote
  #8  
Old April 18th, 2012, 09:43 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,711 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 48 m 5 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
C#? My expression as written for the language would be
Code:
string expression = @"<p class=""row"">\s+<span class=""ih"" id="images:[a-z0-9]+.jpg"">&nbsp;</span>\s+(... ..) - <a href=""http://miami.craigslist.org/[a-z]+/cto/\d+.html"">(.*?) -</a>\s+(\$\d+)<font size=""-1""> (.*?)</font> <small class=""gc""><a href=""/cto/"">owner</a></small> <span class=""p"">.*?</span><br class=""c"">\s+</p>";

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Exression Help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap