Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex help

Status
Not open for further replies.

chris86t

Technical User
Jun 13, 2008
41
0
0
US
I'm writing a web page parser with VB.NET. I need to use regex to find the info I'm looking for, but have zero regex experience.

I need to find the following lines:

Code:
<span class="pricing">$119.99</span>

and

Code:
<span class="rebate">$20.00</span>

And just pull out the numbers with the decimal (119.99 or 20.00)

Right now I'm using this regex code:

Code:
"pricing"">*(?:""(?<1>[^""]*)""|(?<1>\S+))"

And it returns:

$119.99</span>

When i want it to return just 119.99

The page I'm pulling from is
 
With pattern Like this.
[tt] 'Dim pattern As String
pattern="(?<=<span\s+[^>]*?class\s*=\s*\k<q>\s*(pricing|rebat)\s*(?<q>(""|'))[^>]*?>\s*\$)([^<]*?)(?=\s*</span>)"[/tt]
 
<span class="rebate">$20.00</span>

No such line exists in the source (at least, not in the example source you ahve provided).

 
Really strongm? It seems to be on line 768 in the link in ther OP's post?

Andy
---------------------------------
[green]' Signature removed for testing purposes.[/green]

 
Oh yes - shows how one loses ones edge when one has had a short holiday ... ;-)
 
Well, after browsing and not finding a solution, I followed some liks from that page and came up with this. It works ok for now.
Code:
"[pricing|rebate]"">\$*(?:""(?<1>[^""]*)""|(?<1>[0-9|\.|\,]+))"

Regex is confusing at first, but then starts to make sense after a bit of reading
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top