ホームページ  >  記事  >  バックエンド開発  >  正規表現を探しています。難しい

正規表現を探しています。難しい

WBOY
WBOYオリジナル
2016-06-23 14:04:121012ブラウズ

$content = '<td align="right">  <b>[1]</b>   <a href=Store.aspx?SessionCode=58152D67C1C34905B5155F2FDE0B0DE5&toc=136337:770291^2^1|136337^0^752&GetProducts=1&SelectedAttributes=33111116327|741&PRL=1_232.22%257e588.14%257e%2524232.22%2b%2b-%2b%2b%2524588.14%2b(369)_2_588.69%257e729.2%257e%2524588.69%2b%2b-%2b%2b%2524729.20%2b(371)_3_729.99%257e879.64%257e%2524729.99%2b%2b-%2b%2b%2524879.64%2b(372)_4_880.85%257e1078.2467%257e%2524880.85%2b%2b-%2b%2b%25241%252c078.25%2b(369)_5_1079%257e1342.88%257e%25241%252c079.00%2b%2b-%2b%2b%25241%252c342.88%2b(370)_6_1343.28%257e1623.3%257e%25241%252c343.28%2b%2b-%2b%2b%25241%252c623.30%2b(369)_7_1623.66%257e1824.59%257e%25241%252c623.66%2b%2b-%2b%2b%25241%252c824.59%2b(369)_8_1825.2%257e2140.7%257e%25241%252c825.20%2b%2b-%2b%2b%25242%252c140.70%2b(369)_9_2142.24%257e2609.81%257e%25242%252c142.24%2b%2b-%2b%2b%25242%252c609.81%2b(370)_10_2613.21%257e31877.92%257e%25242%252c613.21%2b%2b-%2b%2b%252431%252c877.92%2b(349)&pgno=2>2</a>  <a href=Store.aspx?SessionCode=58152D67C1C34905B5155F2FDE0B0DE5&toc=136337:770291^2^1|136337^0^752&GetProducts=1&SelectedAttributes=33111116327|741&PRL=1_232.22%257e588.14%257e%2524232.22%2b%2b-%2b%2b%2524588.14%2b(369)_2_588.69%257e729.2%257e%2524588.69%2b%2b-%2b%2b%2524729.20%2b(371)_3_729.99%257e879.64%257e%2524729.99%2b%2b-%2b%2b%2524879.64%2b(372)_4_880.85%257e1078.2467%257e%2524880.85%2b%2b-%2b%2b%25241%252c078.25%2b(369)_5_1079%257e1342.88%257e%25241%252c079.00%2b%2b-%2b%2b%25241%252c342.88%2b(370)_6_1343.28%257e1623.3%257e%25241%252c343.28%2b%2b-%2b%2b%25241%252c623.30%2b(369)_7_1623.66%257e1824.59%257e%25241%252c623.66%2b%2b-%2b%2b%25241%252c824.59%2b(369)_8_1825.2%257e2140.7%257e%25241%252c825.20%2b%2b-%2b%2b%25242%252c140.70%2b(369)_9_2142.24%257e2609.81%257e%25242%252c142.24%2b%2b-%2b%2b%25242%252c609.81%2b(370)_10_2613.21%257e31877.92%257e%25242%252c613.21%2b%2b-%2b%2b%252431%252c877.92%2b(349)&pgno=3>3</a><a href="Store.aspx?SessionCode=58152D67C1C34905B5155F2FDE0B0DE5&toc=136337:770291^2^1|136337^0^752&GetProducts=1&SelectedAttributes=33111116327|741&PRL=1_232.22%257e588.14%257e%2524232.22%2b%2b-%2b%2b%2524588.14%2b(369)_2_588.69%257e729.2%257e%2524588.69%2b%2b-%2b%2b%2524729.20%2b(371)_3_729.99%257e879.64%257e%2524729.99%2b%2b-%2b%2b%2524879.64%2b(372)_4_880.85%257e1078.2467%257e%2524880.85%2b%2b-%2b%2b%25241%252c078.25%2b(369)_5_1079%257e1342.88%257e%25241%252c079.00%2b%2b-%2b%2b%25241%252c342.88%2b(370)_6_1343.28%257e1623.3%257e%25241%252c343.28%2b%2b-%2b%2b%25241%252c623.30%2b(369)_7_1623.66%257e1824.59%257e%25241%252c623.66%2b%2b-%2b%2b%25241%252c824.59%2b(369)_8_1825.2%257e2140.7%257e%25241%252c825.20%2b%2b-%2b%2b%25242%252c140.70%2b(369)_9_2142.24%257e2609.81%257e%25242%252c142.24%2b%2b-%2b%2b%25242%252c609.81%2b(370)_10_2613.21%257e31877.92%257e%25242%252c613.21%2b%2b-%2b%2b%252431%252c877.92%2b(349)&pgno=188">Last</a></td>'; $a = preg_match_all('/a href([\S])*/is', $content, $matches); print_r($matches);

専門家の皆様、正規表現を使用して pgno で配列を取得する方法はありますか?
ハイパーリンクの href の最後の &
お願いします。


ディスカッションに返信 (解決策)

$content = '<td align="right">  <b>[1]</b>   <a href=Store.aspx?SessionCode=58152D67C1C34905B5155F2FDE0B0DE5&toc=136337:770291^2^1|136337^0^752&GetProducts=1&SelectedAttributes=33111116327|741&PRL=1_232.22%257e588.14%257e%2524232.22%2b%2b-%2b%2b%2524588.14%2b(369)_2_588.69%257e729.2%257e%2524588.69%2b%2b-%2b%2b%2524729.20%2b(371)_3_729.99%257e879.64%257e%2524729.99%2b%2b-%2b%2b%2524879.64%2b(372)_4_880.85%257e1078.2467%257e%2524880.85%2b%2b-%2b%2b%25241%252c078.25%2b(369)_5_1079%257e1342.88%257e%25241%252c079.00%2b%2b-%2b%2b%25241%252c342.88%2b(370)_6_1343.28%257e1623.3%257e%25241%252c343.28%2b%2b-%2b%2b%25241%252c623.30%2b(369)_7_1623.66%257e1824.59%257e%25241%252c623.66%2b%2b-%2b%2b%25241%252c824.59%2b(369)_8_1825.2%257e2140.7%257e%25241%252c825.20%2b%2b-%2b%2b%25242%252c140.70%2b(369)_9_2142.24%257e2609.81%257e%25242%252c142.24%2b%2b-%2b%2b%25242%252c609.81%2b(370)_10_2613.21%257e31877.92%257e%25242%252c613.21%2b%2b-%2b%2b%252431%252c877.92%2b(349)&pgno=2>2</a>  <a href=Store.aspx?SessionCode=58152D67C1C34905B5155F2FDE0B0DE5&toc=136337:770291^2^1|136337^0^752&GetProducts=1&SelectedAttributes=33111116327|741&PRL=1_232.22%257e588.14%257e%2524232.22%2b%2b-%2b%2b%2524588.14%2b(369)_2_588.69%257e729.2%257e%2524588.69%2b%2b-%2b%2b%2524729.20%2b(371)_3_729.99%257e879.64%257e%2524729.99%2b%2b-%2b%2b%2524879.64%2b(372)_4_880.85%257e1078.2467%257e%2524880.85%2b%2b-%2b%2b%25241%252c078.25%2b(369)_5_1079%257e1342.88%257e%25241%252c079.00%2b%2b-%2b%2b%25241%252c342.88%2b(370)_6_1343.28%257e1623.3%257e%25241%252c343.28%2b%2b-%2b%2b%25241%252c623.30%2b(369)_7_1623.66%257e1824.59%257e%25241%252c623.66%2b%2b-%2b%2b%25241%252c824.59%2b(369)_8_1825.2%257e2140.7%257e%25241%252c825.20%2b%2b-%2b%2b%25242%252c140.70%2b(369)_9_2142.24%257e2609.81%257e%25242%252c142.24%2b%2b-%2b%2b%25242%252c609.81%2b(370)_10_2613.21%257e31877.92%257e%25242%252c613.21%2b%2b-%2b%2b%252431%252c877.92%2b(349)&pgno=3>3</a><a href="Store.aspx?SessionCode=58152D67C1C34905B5155F2FDE0B0DE5&toc=136337:770291^2^1|136337^0^752&GetProducts=1&SelectedAttributes=33111116327|741&PRL=1_232.22%257e588.14%257e%2524232.22%2b%2b-%2b%2b%2524588.14%2b(369)_2_588.69%257e729.2%257e%2524588.69%2b%2b-%2b%2b%2524729.20%2b(371)_3_729.99%257e879.64%257e%2524729.99%2b%2b-%2b%2b%2524879.64%2b(372)_4_880.85%257e1078.2467%257e%2524880.85%2b%2b-%2b%2b%25241%252c078.25%2b(369)_5_1079%257e1342.88%257e%25241%252c079.00%2b%2b-%2b%2b%25241%252c342.88%2b(370)_6_1343.28%257e1623.3%257e%25241%252c343.28%2b%2b-%2b%2b%25241%252c623.30%2b(369)_7_1623.66%257e1824.59%257e%25241%252c623.66%2b%2b-%2b%2b%25241%252c824.59%2b(369)_8_1825.2%257e2140.7%257e%25241%252c825.20%2b%2b-%2b%2b%25242%252c140.70%2b(369)_9_2142.24%257e2609.81%257e%25242%252c142.24%2b%2b-%2b%2b%25242%252c609.81%2b(370)_10_2613.21%257e31877.92%257e%25242%252c613.21%2b%2b-%2b%2b%252431%252c877.92%2b(349)&pgno=188">Last</a></td>';preg_match_all('/pgno=(\d+)/is', $content, $m);print_r($m[1]);/**Array ( [0] => 2 [1] => 3 [2] => 188 )*/

PHP code?12345678910$content = '9f6f3b2738ca140c18fcab668911811f[1]0d36329ec37a2cc24d42c7229b69747a cebb739570f62205f3c198827a6e0ae2a4b561c25d9afb9ac8dc4d70affff419[1]40ea0265725dd3924787f34c888ed5f5 &nbsp;a4b561c25d9afb9ac8dc4d70affff419[1]0d36329ec37a2cc24d42c7229b69747a ; うーん