rascle Posted July 4, 2011 Share Posted July 4, 2011 Hi, Basically I am taking some data from a website, and am storing it in a file called dump.text, I am then using preg_match to find a line in the file, that I need to get some variable information from. I have managed to get the file working but cant seem to get the preg_match bit working: preg_match('/<td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR<\/a><\/td>\s+ <td\s+class="data changeUp"> \s+ <img\s+width="9"\s+height="10"\s+src="/resources_v2/images/changeUp.gif"\s+\/>(.*?)<\/td>/si', $eurovalue, $euroarray); does anyone know what is wrong with it, all I want it to do is to find that line and then below that I echo it, however it doesnt display anything (I would expect it to display the line above). I have checked my dump.text file and the it is working from that end. I have added in things such as /'s, \'s and +si, I dont really know what they are for but have used them in previous codes. Can anyone tell me what I am doing wrong (before you ask I have looked at the php documentation for this but couldnt really see any answer) Thanks Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/ Share on other sites More sharing options...
xyph Posted July 4, 2011 Share Posted July 4, 2011 RegEx isn't meant to parse HTML. If you post the data and what you want I can build you a RegEx that will work for that particular dataset. Whether it works on the next instance you scrape the page, I can't promise. Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238318 Share on other sites More sharing options...
rascle Posted July 4, 2011 Author Share Posted July 4, 2011 I use the same method to get information from a different website (with HTML) that works fine (see http://www.phpfreaks.com/forums/index.php?topic=328096.msg1544543#msg1544543, topic was solved by MrXHellboy), so I am pretty sure it is possible to do it, I just have something wrong with my code. Thanks Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238343 Share on other sites More sharing options...
xyph Posted July 4, 2011 Share Posted July 4, 2011 You're not understanding what I'm saying. If you want to parse the content, google PHP DOM Parser. If you'd like me to show you a more simplified RegEx that may work for the content you provide, please show me what you're trying to extract, and what you're trying to extract it from, in full. Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238357 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 Basically the code below is what I need to get the information from: <html> <head> </head> <body> <div id="col03"> <input name="CurrenciesConversion:Convert" id="CurrenciesConversion_Convert" type="button" onclick="javascript:ConvertCurrency('/business/currencies/quote?srcAmt=[amt]&srcCurr=[from]&destAmt=&destCurr=[to]&historicalDate=[date]','CurrenciesConversion_ConversionAmount','CurrenciesConversion_FromCurrencies','CurrenciesConversion_ToCurrencies','CurrenciesConversion_HistoricalDate');" /> </div> <input name="CurrenciesConversion:HistoricalDate" type="hidden" id="CurrenciesConversion_HistoricalDate"/> <div id="converterFooter"> Exchange Rate For <span id="CurrenciesConversion_HistoricalDate_span">5 Jul 2011</span> <img src="/resources/images/icon_calendar.gif" border="0" id="calIcon" /> <div class="yuiCalContainer"> <div class="yui-skin-sam"> <div id="calContainer"></div> </div> </div> </div> </form> </div> </div> </div> <div class="linebreak"></div> <div class="linebreak"></div> <div class="module"> <div class="moduleBody"> <div class="moduleHeader"><h3>Overview</h3></div> <img src="http://charts.reuters.com/enhancements/chartapi/chart_api.asp?cmb=wsod&ord=16153921472"eCurrency=USD&baseCurrency=EUR&timezoneOffset=0&dateFormat=US&language=EN&symbol=EUR%3DX&headerType=legend"eType=last&width=540&height=339&duration=365&frequency=1week&display=mountain&uppers=&lowers=&event=&timezoneLabel=&compare=GBP%3D,GBPEUR=X" /> <br> </div> </div> <div class="module"> <div class="moduleHeader"> <h3> Currency Table</h3> </div> <div class="moduleBody"> <table width="100%" cellspacing="0" cellpadding="0" border="0" id="currPairs" class="dataTable"> <tbody><tr> <th width="60">Currency</th> <th width="70" class="data">Last</th> <th class="data">Day High</th> <th class="data">Day Low</th> <th class="data">% Change</th> <th class="data">Bid</th> <th class="data">Ask</th> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.6110</td> <td class="data"> 1.6127</td> <td class="data"> 1.5992</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.17%</td> <td class="data"> 1.6110</td> <td class="data"> 1.6114</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.1130</td> <td class="data"> 1.1139</td> <td class="data"> 1.1052</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.63%</td> <td class="data"> 1.1130</td> <td class="data"> 1.1135</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=USD&destAmt=&destCurr=EUR">USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> <td class="data"> 0.69150</td> <td class="data"> 0.68730</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.47%</td> <td class="data"> 0.69070</td> <td class="data"> 0.69120</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=JPY">GBP/JPY</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />130.54</td> <td class="data"> 130.82</td> <td class="data"> 129.77</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.48%</td> <td class="data"> 130.54</td> <td class="data"> 130.64</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=CHF">GBP/CHF</a></td> <td class="data changeDown"> <img width="9" height="10" src="/resources_v2/images/changeDown.gif" />1.3622</td> <td class="data"> 1.3655</td> <td class="data"> 1.3513</td> <td class="data changeDown"> <img width="9" height="10" src="/resources_v2/images/changeDown.gif" />-0.09%</td> <td class="data"> 1.3622</td> <td class="data"> 1.3632</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=AUD">GBP/AUD</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.5055</td> <td class="data"> 1.5070</td> <td class="data"> 1.4968</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.52%</td> <td class="data"> 1.5055</td> <td class="data"> 1.5065</td> </tr> </tbody></table> </div> </div> <div class="linebreak"></div> <div class="sectionDivider"></div> <div class="module"> <div class="moduleBody"> <div class="topStory"><h1><a href="/article/2011/07/05/markets-sterling-idUKL6E7I50E420110705" >Sterling jumps on unexpected rise in UK services PMI</a> </h1><p> * Sterling hits day's high vs dollar, euro, UK services PMI rises</p> <div class="actionButton breaking"><a href="/article/2011/07/05/markets-sterling-idUKL6E7I50E420110705" >Continue Reading</a> </div> </div></div> </div> <div id="moreSectionNews"><div class="module"> <div class="moduleBody"> <div class="feature"><h2><a href="/article/2011/07/05/idUKL6E7I506V20110705" >Sterling rises after stronger-than expected UK PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:40am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/05/idUKL6E7I506620110705" >Sterling rises after stronger-than expected UK PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:39am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/05/markets-sterling-open-idUKL6E7I503M20110705" >Sterling slips, risks more losses on UK services PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:07am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/04/markets-sterling-close-idUKL6E7I41N920110704" >Sterling flat, risks selling as UK economy struggles</a> </h2><div class="relatedInfo"> <span class="timestamp">04 Jul 2011</span></div> </div><div class="feature"><h2><a href="/article/2011/07/04/markets-sterling-idUKL6E7I40DT20110704" >Sterling supported as risk recovers, outperforms euro</a> </h2><div class="relatedInfo"> <span class="timestamp">04 Jul 2011</span></div> </div></div> </div> </div><script type="text/javascript" src="/resources_v2/js/rcom-next20.js"></script> <script type="text/javascript"> Reuters.n20s.init("ukPoundRpt", ""); </script> <div class="ad"><iframe valign="middle" width="540" height="120" marginheight=0 marginwidth=0 frameborder=0 vspace=0 hspace=0 scrolling=NO src="http://www.dianomioffers.co.uk/smartads.epl?id=599"></iframe></div><div class="linebreak"></div> <div class="linebreak"></div> <div class="ad" id="googleAd"> <script type="text/javascript" src="/resources_v2/js/googleAd.js"></script> <script type="text/javascript"> <!-- var googleAdTitle = new Array("Ads by Google", "What's This?", "320", "330"); var googleAdAlign = "left"; google_ad_client = 'ca-pub-9112069016589411'; google_ad_output = 'js'; google_max_num_ads = 3; google_safe = 'high'; google_feedback = 'on'; google_ad_type = 'text'; google_color_line = 'ff0000'; google_encoding = 'utf8'; google_language='en'; google_ad_channel = 'UK_Site'; if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (hideGoogleAds) == 'undefined' || hideGoogleAds == false)) { document.write('<scr' + 'ipt language="javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></scr' + 'ipt>'); } --> </script> </div> <div class="linebreak"></div> </div> <div class="column2 gridPanel grid4"> <div class="ad"> <script language="javascript" type="text/javascript"> // krux kseg and kuid from krux header tag var kruxvars = (typeof(kseg)=='undefined'?'':kseg) + (typeof(kuid)=='undefined'?'':kuid); var adsrc = 'uk.reuters/bizfinance/currencies;' +(typeof(n_pbt)=='undefined'?'':n_pbt) +(typeof(srnd)=='undefined'?'':srnd) + kruxvars + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)!='undefined'?tmstmp:12345) + '?'; if ( typeof(AD_TRACKER) != 'undefined' ) { adsrc = AD_TRACKER.processAdSrcType(adsrc); } if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (AD_TRACKER) == 'undefined' || AD_TRACKER.isAdHidden('mpu') == false) && (typeof (hideAd_10033242) == 'undefined' || hideAd_10033242 == false)) { document.write('<scri' + 'pt language="javascript" type="text/javascript" src="http://ad.doubleclick.net/adj/' + adsrc + '"></scri' + 'pt>'); if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV") >= 0) { /* Looks like we don't need this dart, and we are seeing weird clients with Mozilla/2. userAgent*/ //document.write('<a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" target="_blank">'); //document.write('<img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" width="300" height="250" border="0" alt=""></a>'); } } </script> <noscript> <a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;type=mpu;sz=300x250;tile=2;ord=0441?" target="_blank"> <img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;type=mpu;sz=300x250;tile=2;ord=0441?" width="300" height="250" border="0" alt=""> </a> </noscript> </div> <div id="box-for-rbox"></div> <script type="text/javascript"> function rboxReady(evnt) { TRC.drawRBox({mode:'section-vertical',container:'box-for-rbox',category:'auto'}); } Reuters.utils.loadTaboolaWidget = function() { var taboolaLoader = document.createElement('script'); taboolaLoader.async = true; document.getElementsByTagName('head')[0].appendChild(taboolaLoader); if (taboolaLoader.attachEvent) { // support Internet Explorer taboolaLoader.attachEvent("onactivate", rboxReady); } else { taboolaLoader.addEventListener("activate", rboxReady, false); } taboolaLoader.type="text/javascript"; taboolaLoader.src="http://cdn.taboolasyndication.com/libtrc/reuters/rbox.js?dynamic&category"; } if (Reuters.utils.getQueryStringParameter(location.href, "taboola") == "true") { Reuters.utils.loadTaboolaWidget(); } Reuters.utils.loadTaboolaWidget(); </script><div class="linebreak"></div> <div class="ad"><iframe valign="middle" width="300" height="130" marginheight=0 marginwidth=0 frameborder=0 vspace=0 hspace=0 scrolling=NO src="http://www.dianomioffers.co.uk/smartads.epl?id=612"></iframe> </div><div class="linebreak"></div> <div class="linebreak"></div> <div class="section" id="markets-module"> <div class="sectionContent"> <link href="/resources_v2/css/rcom-markets-module.css" rel="stylesheet" /><div class="linebreak"></div> <div id="mm-header"><div class="module"> <div class="moduleHeader"><h3>Markets</h3></div> </div></div><!-- otherwise tab1Name is empty --> <!-- otherwise tab1Target is empty --> <script src="/resources_v2/js/tabs.js"></script> <div class="linebreak"></div> <div id="mm-tabs"><div class="tabs"> <ul> <li id="MM-tabs_0" class=""><span class="hrefClone">Europe</span></li> <li id="MM-tabs_1" class=""><span class="hrefClone">U.S.</span></li> <li id="MM-tabs_2" class=""><span class="hrefClone">Asia</span></li> <li id="MM-tabs_3" class=""><span class="hrefClone">Sectors</span></li> </ul> <script type="text/javascript"> RTR_Tabs.addTabGroup("MM-tabs", "", "standard", "", "", ""); RTR_Tabs.addTab("MM-tabs_0", "tab1"); RTR_Tabs.addTab("MM-tabs_1", "tab2"); RTR_Tabs.addTab("MM-tabs_2", "tab3"); RTR_Tabs.addTab("MM-tabs_3", "tab4"); RTR_Tabs.init("MM-tabs"); </script> </div> <script type="text/javascript"> RTR_Tabs.hiLiteTab("MM-tabs_0"); </script> </div><style> .marketslogo{ z-index:1000000; background-color:#eaf5f6; /* padding: 12px 12px 12px 125px; */ padding-left:10px; } </style><div class="marketslogo"> <script language="javascript" type="text/javascript"> // krux kseg and kuid from krux header tag var kruxvars = (typeof(kseg)=='undefined'?'':kseg) + (typeof(kuid)=='undefined'?'':kuid); var adsrc = 'uk.reuters/bizfinance/currencies;' +(typeof(n_pbt)=='undefined'?'':n_pbt) +(typeof(srnd)=='undefined'?'':srnd) + kruxvars + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)!='undefined'?tmstmp:12345) + '?'; if ( typeof(AD_TRACKER) != 'undefined' ) { adsrc = AD_TRACKER.processAdSrcType(adsrc); } if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (AD_TRACKER) == 'undefined' || AD_TRACKER.isAdHidden('marketslogo') == false) && (typeof (hideAd_14718067) == 'undefined' || hideAd_14718067 == false)) { document.write('<scri' + 'pt language="javascript" type="text/javascript" src="http://ad.doubleclick.net/adj/' + adsrc + '"></scri' + 'pt>'); if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV") >= 0) { /* Looks like we don't need this dart, and we are seeing weird clients with Mozilla/2. userAgent*/ //document.write('<a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" target="_blank">'); //document.write('<img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" width="1" height="1" border="0" alt=""></a>'); } } </script> <noscript> <a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=4701?" target="_blank"> <img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=4701?" width="1" height="1" border="0" alt=""> </a> </noscript> </div> <div id="tab1"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_270" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_270" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_270" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_270"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_270() { OnStockSearchSubmit('270'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_270', 'Enter company name or Symbol', searchSubmit_270); document.getElementById('btnStockSearchSubmit_270').onclick = searchSubmit_270; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=gb%21ftse">FTSE 100</a></td> <td class="data size8" valign="middle">6,035.82</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +18.28</td> <td class="data" valign="middle">+0.30%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=de%21daxx">DAX</a></td> <td class="data size8" valign="middle">7,464.96</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +22.00</td> <td class="data" valign="middle">+0.30%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=fr%21CAC">CAC 40</a></td> <td class="data size8" valign="middle">3,990.63</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -12.48</td> <td class="data" valign="middle">-0.31%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=US%21TRCONTEU.U"> TR Europe</a></td> <td class="data size8" valign="middle">163.04</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.95</td> <td class="data" valign="middle">-0.58%</td> </tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.83%</td> </tr> <tr class="stripe"> <td valign="top"> <a href="/business/commodity?symbol=US@CL.1"> Oil</a></td> <td class="data" valign="top"> 96.61</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.67</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.73%</td> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@C.1"> Corn</a></td> <td class="data" valign="top"> 606.75</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00%</td> </tr> </table> <div class="moreLink"> <a href="/business/commodities?blob=">» All Commodities</a></div></div> </div> </div> <div class="linebreak"></div> </div><div id="tab2" class="hidden"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_690" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_690" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_690" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_690"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_690() { OnStockSearchSubmit('690'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_690', 'Enter company name or Symbol', searchSubmit_690); document.getElementById('btnStockSearchSubmit_690').onclick = searchSubmit_690; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=us%21dji">DOW</a></td> <td class="data size8" valign="middle">12,564.15</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -18.62</td> <td class="data" valign="middle">-0.15%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=us%21spx">S&P 500</a></td> <td class="data size8" valign="middle">1,339.57</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.10</td> <td class="data" valign="middle">-0.01%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=us%21comp">NASDAQ</a></td> <td class="data size8" valign="middle">2,811.31</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -4.72</td> <td class="data" valign="middle">-0.17%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=US%21TRXUS">TR US Index</a></td> <td class="data size8" valign="middle">122.29</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.34</td> <td class="data" valign="middle">-0.28%</td> </tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.83%</td> </tr> <tr class="stripe"> <td valign="top"> <a href="/business/commodity?symbol=US@CL.1"> Oil</a></td> <td class="data" valign="top"> 96.61</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.67</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.73%</td> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@C.1"> Corn</a></td> <td class="data" valign="top"> 606.75</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00%</td> </tr> </table> <div class="moreLink"> <a href="/business/commodities?blob=">» All Commodities</a></div></div> </div> </div> <div class="linebreak"></div> </div><div id="tab3" class="hidden"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_306" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_306" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_306" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_306"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_306() { OnStockSearchSubmit('306'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_306', 'Enter company name or Symbol', searchSubmit_306); document.getElementById('btnStockSearchSubmit_306').onclick = searchSubmit_306; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=jp%21n225">Nikkei</a></td> <td class="data size8" valign="middle">9,972.46</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +7.37</td> <td class="data" valign="middle">+0.07%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=hk%21hsi">Hang Seng</a></td> <td class="data size8" valign="middle">22,747.95</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -22.52</td> <td class="data" valign="middle">-0.10%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=in%21sen"> Sensex</a></td> <td class="data size8" valign="middle">18,744.56</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -69.92</td> <td class="data" valign="middle">-0.37%</td> </tr> <tr></tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238576 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 I then want preg_match to find: <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=USD&destAmt=&destCurr=EUR">USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> Where 0.69070 is subject to change. Once this has happened I want it to save it to a variable called $eurovalue and then I will strip the tags and isolate the value (I can do this my self thanks) Its just the regex for the preg_match I need help with. I hope this is the info you needed. Thanks Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238578 Share on other sites More sharing options...
AbraCadaver Posted July 5, 2011 Share Posted July 5, 2011 I'm not going to pick through all of that, but you're using / as the delimiter and haven't escaped all of them in the pattern. Try using another delimiter so you don't have to escape anything. You can also try this out: http://www.myregextester.com/index.php Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238589 Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 <?php $pattern = '/<td\s*\w*>\s*<img\s*[\w\d]*\s*\/>(\d+)<\/td>/si' preg_match($pattern,$subject,$matches) $eurovalue = $matches[0]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238592 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 AyKay47 - ??? Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238597 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 Basically the post with the long code isnt relevant, it is where the: <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=USD&destAmt=&destCurr=EUR">USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> lies, basically I just want the code above to be found so need to create a regex to find the above code, in the long code, if that makes sense. Thanks Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238598 Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 the regex above should find the 0.69070 in your code...and store it in $matches[0], then set it to the $eurovalue Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238607 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks, but I've tried it and nothing is happening still. Unfortunately I dont know much about Regex and so cant see what you have done, but there are multiple <td></td> lines, does the provided code identify the one I want? <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=USD&destAmt=&destCurr=EUR">USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> As there are similar bits of code, for example USD/GBP Thanks Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238616 Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 I see, <?php $pattern = '/<td><a.*>USD\/EUR<\/a><\/td>.*<td\s*\w*>\s*<img\s*[\w\d]*\s*\/>(\d+)<\/td>/si' preg_match($pattern,$subject,$matches) $eurovalue = $matches[0]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238617 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks again, however I still cant get it to display anything, here is the code I am using: <?php $eurovalue = file_get_contents("dump.txt"); $eurovalue = htmlspecialchars($eurovalue); $pattern = '/<td><a.*>USD\/EUR<\/a><\/td>.*<td\s*\w*>\s*<img\s*[\w\d]*\s*\/>(\d+)<\/td>/si'; preg_match($pattern,$eurovalue,$euroarray); $euroresult = $euroarray[0]; echo $euroresult; ?> I dont know if there is any silly mistakes in there, dump.text is where the HTML is being loaded (and that is working fine). I use htmlspecialchars, as otherwise the output would be in HTML. I hope this doesnt affect the preg_match Thanks Again Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238626 Share on other sites More sharing options...
wildteen88 Posted July 5, 2011 Share Posted July 5, 2011 I hope this doesnt affect the preg_match Yes, that will affect preg_match. Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238629 Share on other sites More sharing options...
xyph Posted July 5, 2011 Share Posted July 5, 2011 You're much better off using a DOM parser, but here <?php $expr = '%USD/EUR</a></td>\s++ <td\ class="data\ changeUp">\s++ <img\ width="9"\ height="10"\ src="/resources_v2/images/changeUp\.gif"\ /> ([0-9.]++) </td>%x'; $str = getHTML(); preg_match( $expr, $str, $match ); print_r( $match ); function getHTML() { return <<<HEREDOC <html> <head> </head> <body> <div id="col03"> <input name="CurrenciesConversion:Convert" id="CurrenciesConversion_Convert" type="button" onclick="javascript:ConvertCurrency('/business/currencies/quote?srcAmt=[amt]&srcCurr=[from]&destAmt=&destCurr=[to]&historicalDate=[date]','CurrenciesConversion_ConversionAmount','CurrenciesConversion_FromCurrencies','CurrenciesConversion_ToCurrencies','CurrenciesConversion_HistoricalDate');" /> </div> <input name="CurrenciesConversion:HistoricalDate" type="hidden" id="CurrenciesConversion_HistoricalDate"/> <div id="converterFooter"> Exchange Rate For <span id="CurrenciesConversion_HistoricalDate_span">5 Jul 2011</span> <img src="/resources/images/icon_calendar.gif" border="0" id="calIcon" /> <div class="yuiCalContainer"> <div class="yui-skin-sam"> <div id="calContainer"></div> </div> </div> </div> </form> </div> </div> </div> <div class="linebreak"></div> <div class="linebreak"></div> <div class="module"> <div class="moduleBody"> <div class="moduleHeader"><h3>Overview</h3></div> <img src="http://charts.reuters.com/enhancements/chartapi/chart_api.asp?cmb=wsod&ord=16153921472"eCurrency=USD&baseCurrency=EUR&timezoneOffset=0&dateFormat=US&language=EN&symbol=EUR%3DX&headerType=legend"eType=last&width=540&height=339&duration=365&frequency=1week&display=mountain&uppers=&lowers=&event=&timezoneLabel=&compare=GBP%3D,GBPEUR=X" /> <br> </div> </div> <div class="module"> <div class="moduleHeader"> <h3> Currency Table</h3> </div> <div class="moduleBody"> <table width="100%" cellspacing="0" cellpadding="0" border="0" id="currPairs" class="dataTable"> <tbody><tr> <th width="60">Currency</th> <th width="70" class="data">Last</th> <th class="data">Day High</th> <th class="data">Day Low</th> <th class="data">% Change</th> <th class="data">Bid</th> <th class="data">Ask</th> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.6110</td> <td class="data"> 1.6127</td> <td class="data"> 1.5992</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.17%</td> <td class="data"> 1.6110</td> <td class="data"> 1.6114</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.1130</td> <td class="data"> 1.1139</td> <td class="data"> 1.1052</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.63%</td> <td class="data"> 1.1130</td> <td class="data"> 1.1135</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=USD&destAmt=&destCurr=EUR">USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> <td class="data"> 0.69150</td> <td class="data"> 0.68730</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.47%</td> <td class="data"> 0.69070</td> <td class="data"> 0.69120</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=JPY">GBP/JPY</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />130.54</td> <td class="data"> 130.82</td> <td class="data"> 129.77</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.48%</td> <td class="data"> 130.54</td> <td class="data"> 130.64</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=CHF">GBP/CHF</a></td> <td class="data changeDown"> <img width="9" height="10" src="/resources_v2/images/changeDown.gif" />1.3622</td> <td class="data"> 1.3655</td> <td class="data"> 1.3513</td> <td class="data changeDown"> <img width="9" height="10" src="/resources_v2/images/changeDown.gif" />-0.09%</td> <td class="data"> 1.3622</td> <td class="data"> 1.3632</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=AUD">GBP/AUD</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.5055</td> <td class="data"> 1.5070</td> <td class="data"> 1.4968</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.52%</td> <td class="data"> 1.5055</td> <td class="data"> 1.5065</td> </tr> </tbody></table> </div> </div> <div class="linebreak"></div> <div class="sectionDivider"></div> <div class="module"> <div class="moduleBody"> <div class="topStory"><h1><a href="/article/2011/07/05/markets-sterling-idUKL6E7I50E420110705" >Sterling jumps on unexpected rise in UK services PMI</a> </h1><p> * Sterling hits day's high vs dollar, euro, UK services PMI rises</p> <div class="actionButton breaking"><a href="/article/2011/07/05/markets-sterling-idUKL6E7I50E420110705" >Continue Reading</a> </div> </div></div> </div> <div id="moreSectionNews"><div class="module"> <div class="moduleBody"> <div class="feature"><h2><a href="/article/2011/07/05/idUKL6E7I506V20110705" >Sterling rises after stronger-than expected UK PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:40am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/05/idUKL6E7I506620110705" >Sterling rises after stronger-than expected UK PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:39am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/05/markets-sterling-open-idUKL6E7I503M20110705" >Sterling slips, risks more losses on UK services PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:07am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/04/markets-sterling-close-idUKL6E7I41N920110704" >Sterling flat, risks selling as UK economy struggles</a> </h2><div class="relatedInfo"> <span class="timestamp">04 Jul 2011</span></div> </div><div class="feature"><h2><a href="/article/2011/07/04/markets-sterling-idUKL6E7I40DT20110704" >Sterling supported as risk recovers, outperforms euro</a> </h2><div class="relatedInfo"> <span class="timestamp">04 Jul 2011</span></div> </div></div> </div> </div><script type="text/javascript" src="/resources_v2/js/rcom-next20.js"></script> <script type="text/javascript"> Reuters.n20s.init("ukPoundRpt", ""); </script> <div class="ad"><iframe valign="middle" width="540" height="120" marginheight=0 marginwidth=0 frameborder=0 vspace=0 hspace=0 scrolling=NO src="http://www.dianomioffers.co.uk/smartads.epl?id=599"></iframe></div><div class="linebreak"></div> <div class="linebreak"></div> <div class="ad" id="googleAd"> <script type="text/javascript" src="/resources_v2/js/googleAd.js"></script> <script type="text/javascript"> <!-- var googleAdTitle = new Array("Ads by Google", "What's This?", "320", "330"); var googleAdAlign = "left"; google_ad_client = 'ca-pub-9112069016589411'; google_ad_output = 'js'; google_max_num_ads = 3; google_safe = 'high'; google_feedback = 'on'; google_ad_type = 'text'; google_color_line = 'ff0000'; google_encoding = 'utf8'; google_language='en'; google_ad_channel = 'UK_Site'; if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (hideGoogleAds) == 'undefined' || hideGoogleAds == false)) { document.write('<scr' + 'ipt language="javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></scr' + 'ipt>'); } --> </script> </div> <div class="linebreak"></div> </div> <div class="column2 gridPanel grid4"> <div class="ad"> <script language="javascript" type="text/javascript"> // krux kseg and kuid from krux header tag var kruxvars = (typeof(kseg)=='undefined'?'':kseg) + (typeof(kuid)=='undefined'?'':kuid); var adsrc = 'uk.reuters/bizfinance/currencies;' +(typeof(n_pbt)=='undefined'?'':n_pbt) +(typeof(srnd)=='undefined'?'':srnd) + kruxvars + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)!='undefined'?tmstmp:12345) + '?'; if ( typeof(AD_TRACKER) != 'undefined' ) { adsrc = AD_TRACKER.processAdSrcType(adsrc); } if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (AD_TRACKER) == 'undefined' || AD_TRACKER.isAdHidden('mpu') == false) && (typeof (hideAd_10033242) == 'undefined' || hideAd_10033242 == false)) { document.write('<scri' + 'pt language="javascript" type="text/javascript" src="http://ad.doubleclick.net/adj/' + adsrc + '"></scri' + 'pt>'); if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV") >= 0) { /* Looks like we don't need this dart, and we are seeing weird clients with Mozilla/2. userAgent*/ //document.write('<a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" target="_blank">'); //document.write('<img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" width="300" height="250" border="0" alt=""></a>'); } } </script> <noscript> <a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;type=mpu;sz=300x250;tile=2;ord=0441?" target="_blank"> <img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;type=mpu;sz=300x250;tile=2;ord=0441?" width="300" height="250" border="0" alt=""> </a> </noscript> </div> <div id="box-for-rbox"></div> <script type="text/javascript"> function rboxReady(evnt) { TRC.drawRBox({mode:'section-vertical',container:'box-for-rbox',category:'auto'}); } Reuters.utils.loadTaboolaWidget = function() { var taboolaLoader = document.createElement('script'); taboolaLoader.async = true; document.getElementsByTagName('head')[0].appendChild(taboolaLoader); if (taboolaLoader.attachEvent) { // support Internet Explorer taboolaLoader.attachEvent("onactivate", rboxReady); } else { taboolaLoader.addEventListener("activate", rboxReady, false); } taboolaLoader.type="text/javascript"; taboolaLoader.src="http://cdn.taboolasyndication.com/libtrc/reuters/rbox.js?dynamic&category"; } if (Reuters.utils.getQueryStringParameter(location.href, "taboola") == "true") { Reuters.utils.loadTaboolaWidget(); } Reuters.utils.loadTaboolaWidget(); </script><div class="linebreak"></div> <div class="ad"><iframe valign="middle" width="300" height="130" marginheight=0 marginwidth=0 frameborder=0 vspace=0 hspace=0 scrolling=NO src="http://www.dianomioffers.co.uk/smartads.epl?id=612"></iframe> </div><div class="linebreak"></div> <div class="linebreak"></div> <div class="section" id="markets-module"> <div class="sectionContent"> <link href="/resources_v2/css/rcom-markets-module.css" rel="stylesheet" /><div class="linebreak"></div> <div id="mm-header"><div class="module"> <div class="moduleHeader"><h3>Markets</h3></div> </div></div><!-- otherwise tab1Name is empty --> <!-- otherwise tab1Target is empty --> <script src="/resources_v2/js/tabs.js"></script> <div class="linebreak"></div> <div id="mm-tabs"><div class="tabs"> <ul> <li id="MM-tabs_0" class=""><span class="hrefClone">Europe</span></li> <li id="MM-tabs_1" class=""><span class="hrefClone">U.S.</span></li> <li id="MM-tabs_2" class=""><span class="hrefClone">Asia</span></li> <li id="MM-tabs_3" class=""><span class="hrefClone">Sectors</span></li> </ul> <script type="text/javascript"> RTR_Tabs.addTabGroup("MM-tabs", "", "standard", "", "", ""); RTR_Tabs.addTab("MM-tabs_0", "tab1"); RTR_Tabs.addTab("MM-tabs_1", "tab2"); RTR_Tabs.addTab("MM-tabs_2", "tab3"); RTR_Tabs.addTab("MM-tabs_3", "tab4"); RTR_Tabs.init("MM-tabs"); </script> </div> <script type="text/javascript"> RTR_Tabs.hiLiteTab("MM-tabs_0"); </script> </div><style> .marketslogo{ z-index:1000000; background-color:#eaf5f6; /* padding: 12px 12px 12px 125px; */ padding-left:10px; } </style><div class="marketslogo"> <script language="javascript" type="text/javascript"> // krux kseg and kuid from krux header tag var kruxvars = (typeof(kseg)=='undefined'?'':kseg) + (typeof(kuid)=='undefined'?'':kuid); var adsrc = 'uk.reuters/bizfinance/currencies;' +(typeof(n_pbt)=='undefined'?'':n_pbt) +(typeof(srnd)=='undefined'?'':srnd) + kruxvars + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)!='undefined'?tmstmp:12345) + '?'; if ( typeof(AD_TRACKER) != 'undefined' ) { adsrc = AD_TRACKER.processAdSrcType(adsrc); } if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (AD_TRACKER) == 'undefined' || AD_TRACKER.isAdHidden('marketslogo') == false) && (typeof (hideAd_14718067) == 'undefined' || hideAd_14718067 == false)) { document.write('<scri' + 'pt language="javascript" type="text/javascript" src="http://ad.doubleclick.net/adj/' + adsrc + '"></scri' + 'pt>'); if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV") >= 0) { /* Looks like we don't need this dart, and we are seeing weird clients with Mozilla/2. userAgent*/ //document.write('<a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" target="_blank">'); //document.write('<img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" width="1" height="1" border="0" alt=""></a>'); } } </script> <noscript> <a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=4701?" target="_blank"> <img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=4701?" width="1" height="1" border="0" alt=""> </a> </noscript> </div> <div id="tab1"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_270" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_270" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_270" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_270"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_270() { OnStockSearchSubmit('270'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_270', 'Enter company name or Symbol', searchSubmit_270); document.getElementById('btnStockSearchSubmit_270').onclick = searchSubmit_270; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=gb%21ftse">FTSE 100</a></td> <td class="data size8" valign="middle">6,035.82</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +18.28</td> <td class="data" valign="middle">+0.30%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=de%21daxx">DAX</a></td> <td class="data size8" valign="middle">7,464.96</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +22.00</td> <td class="data" valign="middle">+0.30%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=fr%21CAC">CAC 40</a></td> <td class="data size8" valign="middle">3,990.63</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -12.48</td> <td class="data" valign="middle">-0.31%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=US%21TRCONTEU.U"> TR Europe</a></td> <td class="data size8" valign="middle">163.04</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.95</td> <td class="data" valign="middle">-0.58%</td> </tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.83%</td> </tr> <tr class="stripe"> <td valign="top"> <a href="/business/commodity?symbol=US@CL.1"> Oil</a></td> <td class="data" valign="top"> 96.61</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.67</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.73%</td> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@C.1"> Corn</a></td> <td class="data" valign="top"> 606.75</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00%</td> </tr> </table> <div class="moreLink"> <a href="/business/commodities?blob=">» All Commodities</a></div></div> </div> </div> <div class="linebreak"></div> </div><div id="tab2" class="hidden"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_690" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_690" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_690" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_690"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_690() { OnStockSearchSubmit('690'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_690', 'Enter company name or Symbol', searchSubmit_690); document.getElementById('btnStockSearchSubmit_690').onclick = searchSubmit_690; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=us%21dji">DOW</a></td> <td class="data size8" valign="middle">12,564.15</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -18.62</td> <td class="data" valign="middle">-0.15%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=us%21spx">S&P 500</a></td> <td class="data size8" valign="middle">1,339.57</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.10</td> <td class="data" valign="middle">-0.01%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=us%21comp">NASDAQ</a></td> <td class="data size8" valign="middle">2,811.31</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -4.72</td> <td class="data" valign="middle">-0.17%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=US%21TRXUS">TR US Index</a></td> <td class="data size8" valign="middle">122.29</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.34</td> <td class="data" valign="middle">-0.28%</td> </tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.83%</td> </tr> <tr class="stripe"> <td valign="top"> <a href="/business/commodity?symbol=US@CL.1"> Oil</a></td> <td class="data" valign="top"> 96.61</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.67</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.73%</td> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@C.1"> Corn</a></td> <td class="data" valign="top"> 606.75</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00%</td> </tr> </table> <div class="moreLink"> <a href="/business/commodities?blob=">» All Commodities</a></div></div> </div> </div> <div class="linebreak"></div> </div><div id="tab3" class="hidden"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_306" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_306" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_306" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_306"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_306() { OnStockSearchSubmit('306'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_306', 'Enter company name or Symbol', searchSubmit_306); document.getElementById('btnStockSearchSubmit_306').onclick = searchSubmit_306; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=jp%21n225">Nikkei</a></td> <td class="data size8" valign="middle">9,972.46</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +7.37</td> <td class="data" valign="middle">+0.07%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=hk%21hsi">Hang Seng</a></td> <td class="data size8" valign="middle">22,747.95</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -22.52</td> <td class="data" valign="middle">-0.10%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=in%21sen"> Sensex</a></td> <td class="data size8" valign="middle">18,744.56</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -69.92</td> <td class="data" valign="middle">-0.37%</td> </tr> <tr></tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> HEREDOC; } ?> outputs Array ( [0] => USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> [1] => 0.69070 ) Your poor RegEx engine though. That's a HUGE string to be parsing. I hope this is something you only execute once a day or so Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238630 Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 You're much better off using a DOM parser, but here <?php $expr = '%USD/EUR</a></td>\s++ <td\ class="data\ changeUp">\s++ <img\ width="9"\ height="10"\ src="/resources_v2/images/changeUp\.gif"\ /> ([0-9.]++) </td>%x'; $str = getHTML(); preg_match( $expr, $str, $match ); print_r( $match ); function getHTML() { return <<<HEREDOC <html> <head> </head> <body> <div id="col03"> <input name="CurrenciesConversion:Convert" id="CurrenciesConversion_Convert" type="button" onclick="javascript:ConvertCurrency('/business/currencies/quote?srcAmt=[amt]&srcCurr=[from]&destAmt=&destCurr=[to]&historicalDate=[date]','CurrenciesConversion_ConversionAmount','CurrenciesConversion_FromCurrencies','CurrenciesConversion_ToCurrencies','CurrenciesConversion_HistoricalDate');" /> </div> <input name="CurrenciesConversion:HistoricalDate" type="hidden" id="CurrenciesConversion_HistoricalDate"/> <div id="converterFooter"> Exchange Rate For <span id="CurrenciesConversion_HistoricalDate_span">5 Jul 2011</span> <img src="/resources/images/icon_calendar.gif" border="0" id="calIcon" /> <div class="yuiCalContainer"> <div class="yui-skin-sam"> <div id="calContainer"></div> </div> </div> </div> </form> </div> </div> </div> <div class="linebreak"></div> <div class="linebreak"></div> <div class="module"> <div class="moduleBody"> <div class="moduleHeader"><h3>Overview</h3></div> <img src="http://charts.reuters.com/enhancements/chartapi/chart_api.asp?cmb=wsod&ord=16153921472"eCurrency=USD&baseCurrency=EUR&timezoneOffset=0&dateFormat=US&language=EN&symbol=EUR%3DX&headerType=legend"eType=last&width=540&height=339&duration=365&frequency=1week&display=mountain&uppers=&lowers=&event=&timezoneLabel=&compare=GBP%3D,GBPEUR=X" /> <br> </div> </div> <div class="module"> <div class="moduleHeader"> <h3> Currency Table</h3> </div> <div class="moduleBody"> <table width="100%" cellspacing="0" cellpadding="0" border="0" id="currPairs" class="dataTable"> <tbody><tr> <th width="60">Currency</th> <th width="70" class="data">Last</th> <th class="data">Day High</th> <th class="data">Day Low</th> <th class="data">% Change</th> <th class="data">Bid</th> <th class="data">Ask</th> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.6110</td> <td class="data"> 1.6127</td> <td class="data"> 1.5992</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.17%</td> <td class="data"> 1.6110</td> <td class="data"> 1.6114</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.1130</td> <td class="data"> 1.1139</td> <td class="data"> 1.1052</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.63%</td> <td class="data"> 1.1130</td> <td class="data"> 1.1135</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=USD&destAmt=&destCurr=EUR">USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> <td class="data"> 0.69150</td> <td class="data"> 0.68730</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.47%</td> <td class="data"> 0.69070</td> <td class="data"> 0.69120</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=JPY">GBP/JPY</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />130.54</td> <td class="data"> 130.82</td> <td class="data"> 129.77</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.48%</td> <td class="data"> 130.54</td> <td class="data"> 130.64</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=CHF">GBP/CHF</a></td> <td class="data changeDown"> <img width="9" height="10" src="/resources_v2/images/changeDown.gif" />1.3622</td> <td class="data"> 1.3655</td> <td class="data"> 1.3513</td> <td class="data changeDown"> <img width="9" height="10" src="/resources_v2/images/changeDown.gif" />-0.09%</td> <td class="data"> 1.3622</td> <td class="data"> 1.3632</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=AUD">GBP/AUD</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />1.5055</td> <td class="data"> 1.5070</td> <td class="data"> 1.4968</td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />+0.52%</td> <td class="data"> 1.5055</td> <td class="data"> 1.5065</td> </tr> </tbody></table> </div> </div> <div class="linebreak"></div> <div class="sectionDivider"></div> <div class="module"> <div class="moduleBody"> <div class="topStory"><h1><a href="/article/2011/07/05/markets-sterling-idUKL6E7I50E420110705" >Sterling jumps on unexpected rise in UK services PMI</a> </h1><p> * Sterling hits day's high vs dollar, euro, UK services PMI rises</p> <div class="actionButton breaking"><a href="/article/2011/07/05/markets-sterling-idUKL6E7I50E420110705" >Continue Reading</a> </div> </div></div> </div> <div id="moreSectionNews"><div class="module"> <div class="moduleBody"> <div class="feature"><h2><a href="/article/2011/07/05/idUKL6E7I506V20110705" >Sterling rises after stronger-than expected UK PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:40am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/05/idUKL6E7I506620110705" >Sterling rises after stronger-than expected UK PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:39am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/05/markets-sterling-open-idUKL6E7I503M20110705" >Sterling slips, risks more losses on UK services PMI</a> </h2><div class="relatedInfo"> <span class="timestamp">9:07am BST</span></div> </div><div class="feature"><h2><a href="/article/2011/07/04/markets-sterling-close-idUKL6E7I41N920110704" >Sterling flat, risks selling as UK economy struggles</a> </h2><div class="relatedInfo"> <span class="timestamp">04 Jul 2011</span></div> </div><div class="feature"><h2><a href="/article/2011/07/04/markets-sterling-idUKL6E7I40DT20110704" >Sterling supported as risk recovers, outperforms euro</a> </h2><div class="relatedInfo"> <span class="timestamp">04 Jul 2011</span></div> </div></div> </div> </div><script type="text/javascript" src="/resources_v2/js/rcom-next20.js"></script> <script type="text/javascript"> Reuters.n20s.init("ukPoundRpt", ""); </script> <div class="ad"><iframe valign="middle" width="540" height="120" marginheight=0 marginwidth=0 frameborder=0 vspace=0 hspace=0 scrolling=NO src="http://www.dianomioffers.co.uk/smartads.epl?id=599"></iframe></div><div class="linebreak"></div> <div class="linebreak"></div> <div class="ad" id="googleAd"> <script type="text/javascript" src="/resources_v2/js/googleAd.js"></script> <script type="text/javascript"> <!-- var googleAdTitle = new Array("Ads by Google", "What's This?", "320", "330"); var googleAdAlign = "left"; google_ad_client = 'ca-pub-9112069016589411'; google_ad_output = 'js'; google_max_num_ads = 3; google_safe = 'high'; google_feedback = 'on'; google_ad_type = 'text'; google_color_line = 'ff0000'; google_encoding = 'utf8'; google_language='en'; google_ad_channel = 'UK_Site'; if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (hideGoogleAds) == 'undefined' || hideGoogleAds == false)) { document.write('<scr' + 'ipt language="javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></scr' + 'ipt>'); } --> </script> </div> <div class="linebreak"></div> </div> <div class="column2 gridPanel grid4"> <div class="ad"> <script language="javascript" type="text/javascript"> // krux kseg and kuid from krux header tag var kruxvars = (typeof(kseg)=='undefined'?'':kseg) + (typeof(kuid)=='undefined'?'':kuid); var adsrc = 'uk.reuters/bizfinance/currencies;' +(typeof(n_pbt)=='undefined'?'':n_pbt) +(typeof(srnd)=='undefined'?'':srnd) + kruxvars + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)!='undefined'?tmstmp:12345) + '?'; if ( typeof(AD_TRACKER) != 'undefined' ) { adsrc = AD_TRACKER.processAdSrcType(adsrc); } if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (AD_TRACKER) == 'undefined' || AD_TRACKER.isAdHidden('mpu') == false) && (typeof (hideAd_10033242) == 'undefined' || hideAd_10033242 == false)) { document.write('<scri' + 'pt language="javascript" type="text/javascript" src="http://ad.doubleclick.net/adj/' + adsrc + '"></scri' + 'pt>'); if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV") >= 0) { /* Looks like we don't need this dart, and we are seeing weird clients with Mozilla/2. userAgent*/ //document.write('<a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" target="_blank">'); //document.write('<img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=mpu;sz=300x250;tile=2;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" width="300" height="250" border="0" alt=""></a>'); } } </script> <noscript> <a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;type=mpu;sz=300x250;tile=2;ord=0441?" target="_blank"> <img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;type=mpu;sz=300x250;tile=2;ord=0441?" width="300" height="250" border="0" alt=""> </a> </noscript> </div> <div id="box-for-rbox"></div> <script type="text/javascript"> function rboxReady(evnt) { TRC.drawRBox({mode:'section-vertical',container:'box-for-rbox',category:'auto'}); } Reuters.utils.loadTaboolaWidget = function() { var taboolaLoader = document.createElement('script'); taboolaLoader.async = true; document.getElementsByTagName('head')[0].appendChild(taboolaLoader); if (taboolaLoader.attachEvent) { // support Internet Explorer taboolaLoader.attachEvent("onactivate", rboxReady); } else { taboolaLoader.addEventListener("activate", rboxReady, false); } taboolaLoader.type="text/javascript"; taboolaLoader.src="http://cdn.taboolasyndication.com/libtrc/reuters/rbox.js?dynamic&category"; } if (Reuters.utils.getQueryStringParameter(location.href, "taboola") == "true") { Reuters.utils.loadTaboolaWidget(); } Reuters.utils.loadTaboolaWidget(); </script><div class="linebreak"></div> <div class="ad"><iframe valign="middle" width="300" height="130" marginheight=0 marginwidth=0 frameborder=0 vspace=0 hspace=0 scrolling=NO src="http://www.dianomioffers.co.uk/smartads.epl?id=612"></iframe> </div><div class="linebreak"></div> <div class="linebreak"></div> <div class="section" id="markets-module"> <div class="sectionContent"> <link href="/resources_v2/css/rcom-markets-module.css" rel="stylesheet" /><div class="linebreak"></div> <div id="mm-header"><div class="module"> <div class="moduleHeader"><h3>Markets</h3></div> </div></div><!-- otherwise tab1Name is empty --> <!-- otherwise tab1Target is empty --> <script src="/resources_v2/js/tabs.js"></script> <div class="linebreak"></div> <div id="mm-tabs"><div class="tabs"> <ul> <li id="MM-tabs_0" class=""><span class="hrefClone">Europe</span></li> <li id="MM-tabs_1" class=""><span class="hrefClone">U.S.</span></li> <li id="MM-tabs_2" class=""><span class="hrefClone">Asia</span></li> <li id="MM-tabs_3" class=""><span class="hrefClone">Sectors</span></li> </ul> <script type="text/javascript"> RTR_Tabs.addTabGroup("MM-tabs", "", "standard", "", "", ""); RTR_Tabs.addTab("MM-tabs_0", "tab1"); RTR_Tabs.addTab("MM-tabs_1", "tab2"); RTR_Tabs.addTab("MM-tabs_2", "tab3"); RTR_Tabs.addTab("MM-tabs_3", "tab4"); RTR_Tabs.init("MM-tabs"); </script> </div> <script type="text/javascript"> RTR_Tabs.hiLiteTab("MM-tabs_0"); </script> </div><style> .marketslogo{ z-index:1000000; background-color:#eaf5f6; /* padding: 12px 12px 12px 125px; */ padding-left:10px; } </style><div class="marketslogo"> <script language="javascript" type="text/javascript"> // krux kseg and kuid from krux header tag var kruxvars = (typeof(kseg)=='undefined'?'':kseg) + (typeof(kuid)=='undefined'?'':kuid); var adsrc = 'uk.reuters/bizfinance/currencies;' +(typeof(n_pbt)=='undefined'?'':n_pbt) +(typeof(srnd)=='undefined'?'':srnd) + kruxvars + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)!='undefined'?tmstmp:12345) + '?'; if ( typeof(AD_TRACKER) != 'undefined' ) { adsrc = AD_TRACKER.processAdSrcType(adsrc); } if ((typeof (hideAllAds) == 'undefined' || hideAllAds == false) && (typeof (AD_TRACKER) == 'undefined' || AD_TRACKER.isAdHidden('marketslogo') == false) && (typeof (hideAd_14718067) == 'undefined' || hideAd_14718067 == false)) { document.write('<scri' + 'pt language="javascript" type="text/javascript" src="http://ad.doubleclick.net/adj/' + adsrc + '"></scri' + 'pt>'); if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV") >= 0) { /* Looks like we don't need this dart, and we are seeing weird clients with Mozilla/2. userAgent*/ //document.write('<a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" target="_blank">'); //document.write('<img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;' + (typeof(seg)=='undefined'?'':seg) + 'type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=' + (typeof(tmstmp)=='undefined'?12345:tmstmp) + '?" width="1" height="1" border="0" alt=""></a>'); } } </script> <noscript> <a href="http://ad.doubleclick.net/jump/uk.reuters/bizfinance/currencies;type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=4701?" target="_blank"> <img src="http://ad.doubleclick.net/ad/uk.reuters/bizfinance/currencies;type=marketslogo;sz=1x1;taga=aaaaaaaaa;ord=4701?" width="1" height="1" border="0" alt=""> </a> </noscript> </div> <div id="tab1"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_270" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_270" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_270" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_270"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_270() { OnStockSearchSubmit('270'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_270', 'Enter company name or Symbol', searchSubmit_270); document.getElementById('btnStockSearchSubmit_270').onclick = searchSubmit_270; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=gb%21ftse">FTSE 100</a></td> <td class="data size8" valign="middle">6,035.82</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +18.28</td> <td class="data" valign="middle">+0.30%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=de%21daxx">DAX</a></td> <td class="data size8" valign="middle">7,464.96</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +22.00</td> <td class="data" valign="middle">+0.30%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=fr%21CAC">CAC 40</a></td> <td class="data size8" valign="middle">3,990.63</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -12.48</td> <td class="data" valign="middle">-0.31%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=US%21TRCONTEU.U"> TR Europe</a></td> <td class="data size8" valign="middle">163.04</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.95</td> <td class="data" valign="middle">-0.58%</td> </tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.83%</td> </tr> <tr class="stripe"> <td valign="top"> <a href="/business/commodity?symbol=US@CL.1"> Oil</a></td> <td class="data" valign="top"> 96.61</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.67</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.73%</td> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@C.1"> Corn</a></td> <td class="data" valign="top"> 606.75</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00%</td> </tr> </table> <div class="moreLink"> <a href="/business/commodities?blob=">» All Commodities</a></div></div> </div> </div> <div class="linebreak"></div> </div><div id="tab2" class="hidden"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_690" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_690" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_690" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_690"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_690() { OnStockSearchSubmit('690'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_690', 'Enter company name or Symbol', searchSubmit_690); document.getElementById('btnStockSearchSubmit_690').onclick = searchSubmit_690; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=us%21dji">DOW</a></td> <td class="data size8" valign="middle">12,564.15</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -18.62</td> <td class="data" valign="middle">-0.15%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=us%21spx">S&P 500</a></td> <td class="data size8" valign="middle">1,339.57</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.10</td> <td class="data" valign="middle">-0.01%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=us%21comp">NASDAQ</a></td> <td class="data size8" valign="middle">2,811.31</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -4.72</td> <td class="data" valign="middle">-0.17%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=US%21TRXUS">TR US Index</a></td> <td class="data size8" valign="middle">122.29</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -0.34</td> <td class="data" valign="middle">-0.28%</td> </tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.83%</td> </tr> <tr class="stripe"> <td valign="top"> <a href="/business/commodity?symbol=US@CL.1"> Oil</a></td> <td class="data" valign="top"> 96.61</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.67</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +1.73%</td> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@C.1"> Corn</a></td> <td class="data" valign="top"> 606.75</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00</td> <td class="data changeNone" nowrap="nowrap" valign="top"> +0.00%</td> </tr> </table> <div class="moreLink"> <a href="/business/commodities?blob=">» All Commodities</a></div></div> </div> </div> <div class="linebreak"></div> </div><div id="tab3" class="hidden"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/markets/indices?blob="> Market Indices</a> </h3> </div> <div class="moduleBody"> <link href="/resources_v2/css/rcom-stockSearch.css" rel="stylesheet" /> <div class="module investingControlsContainer"> <div class="moduleBody investingControls"> <script language="javascript" type="text/javascript"> function OnClickGo(inputs, symbol) { try { if(inputs.length) { for(var i = 0;i < inputs.length;i++) { if(inputs[i].checked) { var url = inputs[i].value; url = url.replace("[ric]", symbol); document.location.href = url; break; } } } else { var url = inputs.value; url = url.replace("[ric]", symbol); document.location.href = url; } }catch(e){} } function OnStockSearchSubmit(sId) { var stockSearch = 'stockSearch_'+sId; var stockSearchSymbol = 'stockSearchSymbol_'+sId; var stockSearchType = 'stockSearchType_'+sId; try { var symbol = document.getElementById(stockSearchSymbol).value; if(symbol === "" || symbol === "Enter company name or Symbol") { return false; } else { eval('OnClickGo(document.forms["'+stockSearch+'"].'+stockSearchType+', encodeURIComponent(symbol))'); } }catch(e){} } </script> <form name="stockSearch_306" > <div class="stockSearchContainer"> <div class="searchInput"> <input type="hidden" name="stockSearchType_306" value="/business/quotes/lookup?searchType=any&search=[ric]" checked="checked" /> <span class="uppercase bold label">Stock Search</span> </div> <div class="searchInput2"> <div class="searchbox"> <input type="text" class="searchfield" id="stockSearchSymbol_306" name="stockSearchSymbol" value="Enter company name or Symbol" /> <input type="image""class="searchbutton" src="/resources_v2/images/btn_header_go.gif" id="btnStockSearchSubmit_306"/> </div> </div> </div> </form> </div> </div> <script language="javascript" type="text/javascript"> function searchSubmit_306() { OnStockSearchSubmit('306'); return false; } Reuters.utils.enableSearchBox('stockSearchSymbol_306', 'Enter company name or Symbol', searchSubmit_306); document.getElementById('btnStockSearchSubmit_306').onclick = searchSubmit_306; </script><table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"> <tbody class="dataSmall"> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=jp%21n225">Nikkei</a></td> <td class="data size8" valign="middle">9,972.46</td> <td class="data dataUp" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowPos.gif"> +7.37</td> <td class="data" valign="middle">+0.07%</td> </tr> <tr><td valign="middle"><a href="/business/markets/index?symbol=hk%21hsi">Hang Seng</a></td> <td class="data size8" valign="middle">22,747.95</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -22.52</td> <td class="data" valign="middle">-0.10%</td> </tr> <tr class="stripe"><td valign="middle"><a href="/business/markets/index?symbol=in%21sen"> Sensex</a></td> <td class="data size8" valign="middle">18,744.56</td> <td class="data dataDown" valign="middle" ><img height="6" width="11" src="/resources_v2/images/arrowNeg.gif"> -69.92</td> <td class="data" valign="middle">-0.37%</td> </tr> <tr></tr> </table> <div class="moreLink"> <a href="/business/markets/indices?blob=">» All Indices</a></div></div> </div> <div class="linebreak"></div> <div class="mm-currencies"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/currencies?blob="> Currencies</a> </h3> </div> <div class="moduleBody"> <table cellspacing="1" cellpadding="1" width="100%" border="0" id="currPairs" class="dataTable"> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=USD">GBP/USD</a></td> <td class="data bold"> 1.6110</td> <td class="data dataUp bold"> +0.17%</td> </tr> <tr class="stripe"> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=GBP&destAmt=&destCurr=EUR">GBP/EUR</a></td> <td class="data bold"> 1.1130</td> <td class="data dataUp bold"> +0.63%</td> </tr> <tr class=""> <td><a href="/business/currencies/quote?srcAmt=1&srcCurr=EUR&destAmt=&destCurr=USD">EUR/USD</a></td> <td class="data bold"> 1.4471</td> <td class="data dataDown bold"> -0.45%</td> </tr> </tbody></table> <div class="moreLink"> <a href="/business/currencies?blob=">» All Currencies</a></div></div> </div> </div> <div class="linebreak"></div> <div class="mm-commodities"><div class="module"> <div class="moduleHeader"> <h3> <a href="/business/commodities?blob="> Commodities</a> </h3> </div> <div class="moduleBody"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="dataTable"><tbody class="dataSmall"> <tr> </tr> <tr> <td valign="top"> <a href="/business/commodity?symbol=US@GC.1"> Gold</a></td> <td class="data" valign="top"> 1,510.30</td> <td class="data changeUp" nowrap="nowrap" valign="top"> +27.70</td> <td class="data changeUp" nowrap="nowrap" valign="top"> HEREDOC; } ?> outputs Array ( [0] => USD/EUR</a></td> <td class="data changeUp"> <img width="9" height="10" src="/resources_v2/images/changeUp.gif" />0.69070</td> [1] => 0.69070 ) Your poor RegEx engine though. That's a HUGE string to be parsing. I hope this is something you only execute once a day or so that will work as long as nothing in the pattern is subject to change Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238631 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks, sorry to be an idiot but how could I do that by getting the info from dump.text though? Thanks Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238632 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 Whats wrong with just using preg_match? As there is a lot less code? Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238634 Share on other sites More sharing options...
xyph Posted July 5, 2011 Share Posted July 5, 2011 You're not an idiot, you're just coding well beyond your current knowledge/skill set. I'm not going to give you the complete, working solution as that would be coding for you - something I do professionally to some extent. Giving out my services for free would be kind of counter productive. A combination of your code and mine, copied and pasted, should work fine. Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238636 Share on other sites More sharing options...
rascle Posted July 5, 2011 Author Share Posted July 5, 2011 Ok Thanks Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1238638 Share on other sites More sharing options...
rascle Posted July 7, 2011 Author Share Posted July 7, 2011 BTW on the DOM Parser, there is an error "Parse error: syntax error, unexpected '=' in /home/b25rasc/public_html/test9.php on line 2" Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1239666 Share on other sites More sharing options...
rascle Posted July 7, 2011 Author Share Posted July 7, 2011 Sorry, that was the character encoding Quote Link to comment https://forums.phpfreaks.com/topic/241081-preg_match-help/#findComment-1239667 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.