![]() |
Why won't negative sign come over with negative numbers?
We have a script that we are using that I believe is using regular
expressions (which I am very unfamiliar with) to pull data from a web page source. The data is temperatures, but if the temperatures are below zero, the minus sign is not pulled even though it is on the website, just the number is pulled. I have copied and pasted what I believe to be the relevant portions on the VBA below, but if needed, I can post the entire script. Many thanks! For Each c In rng sURLdate = Format(c.Value2, "yyyy/m/d") c.Offset(0, i + 1).Value = RegexMid(myStr, sURLdate, "bl gb") c.Offset(0, i + 2).Value = RegexMid(myStr, sURLdate, "br gb") c.Offset(0, i + 3).Value = RegexMid(myStr, sURLdate, "class=gb") Next c *****Below is the expression referenced above Private Function RegexMid(s As String, sDate As String, sTempType As String) As String Dim re As Object, mc As Object Set re = CreateObject("vbscript.regexp") re.IgnoreCase = True re.MultiLine = True re.Global = True re.Pattern = "\b" & sDate & "/DailyHistory[\s\S]+?" & sTempType & "\D+(\d+)" If re.test(s) = True Then Set mc = re.Execute(s) RegexMid = mc(0).submatches(0) End If Set re = Nothing End Function *****Below is a sample of the source data from the website http://www.wunderground.com/history/...q_statename=NA <td<a href="/history/airport/KSTP/2009/1/27/DailyHistory.html"27</a</td <td class="bl gb" 10 </td <td class="gb" 4 </td <td class="br gb" -2 </td |
Why won't negative sign come over with negative numbers?
If you don't get a good answer here, try this site:
http://social.technet.microsoft.com/...S/ITCG/threads "Jason" wrote in message ... We have a script that we are using that I believe is using regular expressions (which I am very unfamiliar with) to pull data from a web page source. The data is temperatures, but if the temperatures are below zero, the minus sign is not pulled even though it is on the website, just the number is pulled. I have copied and pasted what I believe to be the relevant portions on the VBA below, but if needed, I can post the entire script. Many thanks! For Each c In rng sURLdate = Format(c.Value2, "yyyy/m/d") c.Offset(0, i + 1).Value = RegexMid(myStr, sURLdate, "bl gb") c.Offset(0, i + 2).Value = RegexMid(myStr, sURLdate, "br gb") c.Offset(0, i + 3).Value = RegexMid(myStr, sURLdate, "class=gb") Next c *****Below is the expression referenced above Private Function RegexMid(s As String, sDate As String, sTempType As String) As String Dim re As Object, mc As Object Set re = CreateObject("vbscript.regexp") re.IgnoreCase = True re.MultiLine = True re.Global = True re.Pattern = "\b" & sDate & "/DailyHistory[\s\S]+?" & sTempType & "\D+(\d+)" If re.test(s) = True Then Set mc = re.Execute(s) RegexMid = mc(0).submatches(0) End If Set re = Nothing End Function *****Below is a sample of the source data from the website http://www.wunderground.com/history/...q_statename=NA <td<a href="/history/airport/KSTP/2009/1/27/DailyHistory.html"27</a</td <td class="bl gb" 10 </td <td class="gb" 4 </td <td class="br gb" -2 </td |
All times are GMT +1. The time now is 02:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com