Регулярное выражение, парсинг числа

Discussion in 'PHP' started by egorea1999, 6 Dec 2013.

  1. egorea1999

    egorea1999 New Member

    Joined:
    4 Dec 2011
    Messages:
    15
    Likes Received:
    0
    Reputations:
    0
    Всем привет!

    HTML:
    		<tr id="transactionDetailsRow-57" class="itemInvoiceNumber">
        					<td><label id="transactionRowDate-57" class="transactionRowCell transactionRowDate">05/30/2013</label></td>
        					<td><label id="transactionRowTypeDetailName-57" class="transactionRowCell transactionRowTypeDetailName">Product Purchase</label></td>
        					<td class="accountColumn"><label id="transactionRowAccount-57" class="transactionRowCell transactionRowAccount">[email protected]</label></td>
        					<td><label id="transactionRowCurrency-57" class="transactionRowCell transactionRowCurrency">($3.99)</label></td>
        				</tr>
        			    				<tr id="transactionDetailsRow-58" class="itemInvoiceNumber">
        					<td><label id="transactionRowDate-58" class="transactionRowCell transactionRowDate">05/17/2013</label></td>
        					<td><label id="transactionRowTypeDetailName-58" class="transactionRowCell transactionRowTypeDetailName">Product Purchase</label></td>
        					<td class="accountColumn"><label id="transactionRowAccount-58" class="transactionRowCell transactionRowAccount">[email protected]</label></td>
        					<td><label id="transactionRowCurrency-58" class="transactionRowCell transactionRowCurrency">($0.99)</label></td>
        				</tr>
        			    				<tr id="transactionDetailsRow-59" class="itemInvoiceNumber">
        					<td><label id="transactionRowDate-59" class="transactionRowCell transactionRowDate">05/14/2013</label></td>
        					<td><label id="transactionRowTypeDetailName-59" class="transactionRowCell transactionRowTypeDetailName">Product Purchase</label></td>
        					<td class="accountColumn"><label id="transactionRowAccount-59" class="transactionRowCell transactionRowAccount">[email protected]</label></td>
        					<td><label id="transactionRowCurrency-59" class="transactionRowCell transactionRowCurrency">($4.99)</label></td>
        				</tr>
        			    				<tr id="transactionDetailsRow-60" class="itemInvoiceNumber">
        					<td><label id="transactionRowDate-60" class="transactionRowCell transactionRowDate">05/14/2013</label></td>
        					<td><label id="transactionRowTypeDetailName-60" class="transactionRowCell transactionRowTypeDetailName">Wallet Funding</label></td>
        					<td class="accountColumn"><label id="transactionRowAccount-60" class="transactionRowCell transactionRowAccount">[email protected]</label></td>
        					<td><label id="transactionRowCurrency-60" class="transactionRowCell transactionRowCurrency">$10.00</label></td>
        				</tr>
        			    				<tr id="transactionDetailsRow-61" class="itemInvoiceNumber">
        					<td><label id="transactionRowDate-61" class="transactionRowCell transactionRowDate">05/11/2013</label></td>
        					<td><label id="transactionRowTypeDetailName-61" class="transactionRowCell transactionRowTypeDetailName">Product Purchase</label></td>
        					<td class="accountColumn"><label id="transactionRowAccount-61" class="transactionRowCell transactionRowAccount">[email protected]</label></td>
        					<td><label id="transactionRowCurrency-61" class="transactionRowCell transactionRowCurrency">$0.00</label></td>
        				</tr>
    мне нужно скопировать цифру отсюда:
    <td><label id="transactionRowCurrency-59" class="transactionRowCell transactionRowCurrency">(
    59 - цифра, которую нужно спарсить и только её!!!
    Важно!!
    нужно чтобы именно в конце была скобка- "(" , если в конце нету скобки - "(" , то не надо парсить это число
    на пример:
    <td><label id="transactionRowCurrency-56" class="transactionRowCell transactionRowCurrency">$ - не надо парсить число
    <td><label id="transactionRowCurrency-59" class="transactionRowCell transactionRowCurrency">($ - надо парсить число!

    У меня получилась такая регулярка <td><label id="transactionRowCurrency-(.*?)" class="transactionRowCell transactionRowCurrency"> , но она парсит все числа со скобками и без...

    заранее благодарю!
     
  2. mironich

    mironich Elder - Старейшина

    Joined:
    27 Feb 2011
    Messages:
    733
    Likes Received:
    73
    Reputations:
    19
    Code:
    <label id="transactionRowCurrency-(\d+)"\sclass="transactionRowCell transactionRowCurrency">\(
     
  3. egorea1999

    egorea1999 New Member

    Joined:
    4 Dec 2011
    Messages:
    15
    Likes Received:
    0
    Reputations:
    0
    HTML:
    												</td>
    										<td class="productTitleGroup">
    											<div class="ellipsisOuterWrapper">
    												<div class="ellipsisInnerWrapper">
    													<section class="productTitleSection">DC Universe&trade; Online Free to Play</section>
    													<label class="smallLabel productPublisherSection">SONY ONLINE ENTERTAINMENT LLC</label>
    												</div>
    											</div>
    										</td>
    										<td class="productTypeSection">									 
    											Game													
    										</td>
    										<td class="productPurchasedSection">											
    											        				                        																																													<label class="purchaseDate">10/11/2013</label>
    																					</td>
    										<td class="productExpiresSection">
    											                            				                            				<label class="expirationDate">--</label>
    										</td>
    									</tr>        																			
    																	                            			                    					                    					                            			                            																													<tr>
    										<td class="productImageSection">
    											<input id="mediaItemId_4" class="mediaItemId" type="hidden" value="EP0017-NPEA00266_00" />
    											<input id="mediaItemMediaType_4" class="mediaItemMediaType" type="hidden" value="ACCOUNT_SERVICE" />
    																							<img id="productImage4" class="mediaListProductImage" src="https://apollo2.dl.playstation.net/cdn/EP0017/NPEA00266_00/vpeZ04ln3F7C3ftC48iwNqShOYfBpXJb.png" />
    																					</td>
    										<td class="productTitleGroup">
    											<div class="ellipsisOuterWrapper">
    												<div class="ellipsisInnerWrapper">
    													<section class="productTitleSection">DC UNIVERSE&trade; ONLINE</section>
    													<label class="smallLabel productPublisherSection">SONY ONLINE ENTERTAINMENT LLC</label>
    												</div>
    											</div>
    										</td>
    										<td class="productTypeSection">									 
    											<label class='mediaType'>Game</label><label class='smallLabel typeNameSmallLabel'>Service</label>													
    										</td>
    										<td class="productPurchasedSection">											
    																																												<label class="purchaseDate">10/11/2013</label>
    																					</td>
    										<td class="productExpiresSection">
    а как это вытянуть?
    [​IMG]