php正则表达式 本帖最后由 dengwork 于 2011-07-20 14:20:17 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 preg_match_all('/<a[\d\D]*>\s*(\$[\d\.]+)/i', $str, $matches);print_r($matches[1][0]);/*输出结果:$39.00*/ 很是感谢!要是 是下面的文本 如何获得呢?$25.00Desktop Package Intel E3400 to Intel E5400 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $39.00Desktop Package Intel E3400 to Intel E6500 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $46.99Intel BX80571E3400 CELERON E3400/ 2.60GHz/ 1MB CACHE/ 800FSB/ LGA775 GREENBOXiT (NSW) | www.greenboxit.com.au | updated: 20-07-2011 $47.00BX80571E3400 Intel CPU Celeron Dual Core E3400 / 2.60GHz / 1MB Cache / 800F...Centre Com (VIC) | www.centrecom.com.au | updated: 17-07-2011 $47.00Intel Dual Core Celeron E3400 2.60GHZ (LGA775) CPU Genuine Retail Box MSY (ACT, NSW, QLD, SA, VIC, WA) | www.msy.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Brisbane Southside (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - QLD (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron E3400, 2.60GHz/1MB CACHE/800FSB/LGA775 (BX80571E3400) Gocomp (QLD) | www.gocomp.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 Umart Online - Melbourne (VIC) | www.umart.com.au | updated: 20-07-2011 $48.93Intel Celeron E3400 DC 2.60GHZ 1M Cache [BX80571E3400]E3400 - INTEL CELERON... MegaBuy Technology Superstore (QLD) | www.megabuy.com.au | updated: 20-07-2011 $49.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Sunshine Coast (QLD) | www.umart.com.au | updated: 20-07-2011 $49.00Intel Celeron E3400 Wolfdale 2.6GHz 1MB L2 Cache LGA 775 65W Dual-Core Desk... iiBuy (NSW) | www.iibuy.com.au | updated: 20-07-2011 $50.00CPU/Processor Intel S775 Celeron Dual Core E3400 (2.4GHz) IT Estate (NSW) | www.itestate.com.au | updated: 20-07-2011 $50.82Intel Dual Core Celeron E3400 CPU, 2.60GHz/800MHz FSB/1MB cache/LGA775, Dua...ARC Computers (NSW) | www.arc.com.au | updated: 20-07-2011 $51.00Intel Dual Core Cel E3400 2.6G 1Mb; Dual Core Retail Box HS&F 800Mhz FSB; L... NetPlus (WA) | www.netplus.com.au | updated: 20-07-2011 $51.00Intel Dual Core Celeron E3400 CPU 2.60 GHz 800MHz FSB 1MB cache Socket LGA7...Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.00INTEL BX80571E3400 CELERON E3400 2.60GHz 1MB CACHE 800FSB LGA775Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.11Intel Dual Core Celeron E3400 CPU, 2.60 GHz, 800MHz FSB, 1MB cache, Socket ...Excel Computers (NSW) | www.excelcomputers.com.au | updated: 17-07-2011 $52.75INTEL BX80571E3400 CELERON E3400/2.60GHZ/1MB CACHE/800 ...Computer Wholesale (NSW) | www.computerwholesale.com.au | updated: 15-07-2011 $52.95 <?php $str = "$25.00Desktop Package Intel E3400 to Intel E5400 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $39.00Desktop Package Intel E3400 to Intel E6500 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $46.99Intel BX80571E3400 CELERON E3400/ 2.60GHz/ 1MB CACHE/ 800FSB/ LGA775 GREENBOXiT (NSW) | www.greenboxit.com.au | updated: 20-07-2011 $47.00BX80571E3400 Intel CPU Celeron Dual Core E3400 / 2.60GHz / 1MB Cache / 800F...Centre Com (VIC) | www.centrecom.com.au | updated: 17-07-2011 $47.00Intel Dual Core Celeron E3400 2.60GHZ (LGA775) CPU Genuine Retail Box MSY (ACT, NSW, QLD, SA, VIC, WA) | www.msy.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Brisbane Southside (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - QLD (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron E3400, 2.60GHz/1MB CACHE/800FSB/LGA775 (BX80571E3400) Gocomp (QLD) | www.gocomp.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 Umart Online - Melbourne (VIC) | www.umart.com.au | updated: 20-07-2011 $48.93Intel Celeron E3400 DC 2.60GHZ 1M Cache [BX80571E3400]E3400 - INTEL CELERON... MegaBuy Technology Superstore (QLD) | www.megabuy.com.au | updated: 20-07-2011 $49.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Sunshine Coast (QLD) | www.umart.com.au | updated: 20-07-2011 $49.00Intel Celeron E3400 Wolfdale 2.6GHz 1MB L2 Cache LGA 775 65W Dual-Core Desk... iiBuy (NSW) | www.iibuy.com.au | updated: 20-07-2011 $50.00CPU/Processor Intel S775 Celeron Dual Core E3400 (2.4GHz) IT Estate (NSW) | www.itestate.com.au | updated: 20-07-2011 $50.82Intel Dual Core Celeron E3400 CPU, 2.60GHz/800MHz FSB/1MB cache/LGA775, Dua...ARC Computers (NSW) | www.arc.com.au | updated: 20-07-2011 $51.00Intel Dual Core Cel E3400 2.6G 1Mb; Dual Core Retail Box HS&F 800Mhz FSB; L... NetPlus (WA) | www.netplus.com.au | updated: 20-07-2011 $51.00Intel Dual Core Celeron E3400 CPU 2.60 GHz 800MHz FSB 1MB cache Socket LGA7...Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.00INTEL BX80571E3400 CELERON E3400 2.60GHz 1MB CACHE 800FSB LGA775Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.11Intel Dual Core Celeron E3400 CPU, 2.60 GHz, 800MHz FSB, 1MB cache, Socket ...Excel Computers (NSW) | www.excelcomputers.com.au | updated: 17-07-2011 $52.75INTEL BX80571E3400 CELERON E3400/2.60GHZ/1MB CACHE/800 ...Computer Wholesale (NSW) | www.computerwholesale.com.au | updated: 15-07-2011 $52.95";preg_match_all("/\\$[\d]+[\d\.]*/",$str,$matchs);print_r($matchs); ?> 结果Array( [0] => Array ( [0] => $25.00 [1] => $39.00 [2] => $46.99 [3] => $47.00 [4] => $47.00 [5] => $48.00 [6] => $48.00 [7] => $48.00 [8] => $48.00 [9] => $48.93 [10] => $49.00 [11] => $49.00 [12] => $50.00 [13] => $50.82 [14] => $51.00 [15] => $51.00 [16] => $51.00 [17] => $51.11 [18] => $52.75 [19] => $52.95 )) preg_match_all('/\$\d+\.\d*/is', $str, $matches);print_r($matches[0]); 这种图片展示效果是什么程序做的? php如何运行dbug 急,各位高手帮帮我这个PHP菜鸟!! js代码转成字符串 跪求一个正则表达式!~~~ 一个数据格式问题,在线等,高手来帮帮忙,谢谢了 加了mysql_query('set names utf8'); 不执行sql ecshop导出excel(没有中文乱码) PHPmailer 如何添加暗送 thinkPHP 为什么if标签加上一个条件就不能使用了 用php来做windows漏洞补丁下载,求思路…… 如何用PHP代码 远程控制Linux服务器
preg_match_all('/<a[\d\D]*>\s*(\$[\d\.]+)/i', $str, $matches);
print_r($matches[1][0]);
/*
输出结果:
$39.00
*/
要是 是下面的文本 如何获得呢?$25.00Desktop Package Intel E3400 to Intel E5400 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $39.00Desktop Package Intel E3400 to Intel E6500 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $46.99Intel BX80571E3400 CELERON E3400/ 2.60GHz/ 1MB CACHE/ 800FSB/ LGA775 GREENBOXiT (NSW) | www.greenboxit.com.au | updated: 20-07-2011 $47.00BX80571E3400 Intel CPU Celeron Dual Core E3400 / 2.60GHz / 1MB Cache / 800F...Centre Com (VIC) | www.centrecom.com.au | updated: 17-07-2011 $47.00Intel Dual Core Celeron E3400 2.60GHZ (LGA775) CPU Genuine Retail Box MSY (ACT, NSW, QLD, SA, VIC, WA) | www.msy.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Brisbane Southside (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - QLD (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron E3400, 2.60GHz/1MB CACHE/800FSB/LGA775 (BX80571E3400) Gocomp (QLD) | www.gocomp.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 Umart Online - Melbourne (VIC) | www.umart.com.au | updated: 20-07-2011 $48.93Intel Celeron E3400 DC 2.60GHZ 1M Cache [BX80571E3400]E3400 - INTEL CELERON... MegaBuy Technology Superstore (QLD) | www.megabuy.com.au | updated: 20-07-2011 $49.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Sunshine Coast (QLD) | www.umart.com.au | updated: 20-07-2011 $49.00Intel Celeron E3400 Wolfdale 2.6GHz 1MB L2 Cache LGA 775 65W Dual-Core Desk... iiBuy (NSW) | www.iibuy.com.au | updated: 20-07-2011 $50.00CPU/Processor Intel S775 Celeron Dual Core E3400 (2.4GHz) IT Estate (NSW) | www.itestate.com.au | updated: 20-07-2011 $50.82Intel Dual Core Celeron E3400 CPU, 2.60GHz/800MHz FSB/1MB cache/LGA775, Dua...ARC Computers (NSW) | www.arc.com.au | updated: 20-07-2011 $51.00Intel Dual Core Cel E3400 2.6G 1Mb; Dual Core Retail Box HS&F 800Mhz FSB; L... NetPlus (WA) | www.netplus.com.au | updated: 20-07-2011 $51.00Intel Dual Core Celeron E3400 CPU 2.60 GHz 800MHz FSB 1MB cache Socket LGA7...Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.00INTEL BX80571E3400 CELERON E3400 2.60GHz 1MB CACHE 800FSB LGA775Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.11Intel Dual Core Celeron E3400 CPU, 2.60 GHz, 800MHz FSB, 1MB cache, Socket ...Excel Computers (NSW) | www.excelcomputers.com.au | updated: 17-07-2011 $52.75INTEL BX80571E3400 CELERON E3400/2.60GHZ/1MB CACHE/800 ...Computer Wholesale (NSW) | www.computerwholesale.com.au | updated: 15-07-2011 $52.95
<?php
$str = "
$25.00Desktop Package Intel E3400 to Intel E5400 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $39.00Desktop Package Intel E3400 to Intel E6500 CPU Upgrade Kit PCDIY (NSW, SA, VIC) | www.pcdiy.com.au | updated: 07-05-2011 $46.99Intel BX80571E3400 CELERON E3400/ 2.60GHz/ 1MB CACHE/ 800FSB/ LGA775 GREENBOXiT (NSW) | www.greenboxit.com.au | updated: 20-07-2011 $47.00BX80571E3400 Intel CPU Celeron Dual Core E3400 / 2.60GHz / 1MB Cache / 800F...Centre Com (VIC) | www.centrecom.com.au | updated: 17-07-2011 $47.00Intel Dual Core Celeron E3400 2.60GHZ (LGA775) CPU Genuine Retail Box MSY (ACT, NSW, QLD, SA, VIC, WA) | www.msy.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Brisbane Southside (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - QLD (QLD) | www.umart.com.au | updated: 20-07-2011 $48.00Intel Celeron E3400, 2.60GHz/1MB CACHE/800FSB/LGA775 (BX80571E3400) Gocomp (QLD) | www.gocomp.com.au | updated: 20-07-2011 $48.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 Umart Online - Melbourne (VIC) | www.umart.com.au | updated: 20-07-2011 $48.93Intel Celeron E3400 DC 2.60GHZ 1M Cache [BX80571E3400]E3400 - INTEL CELERON... MegaBuy Technology Superstore (QLD) | www.megabuy.com.au | updated: 20-07-2011 $49.00Intel Celeron Dual Core E3400 2.6GHZ 800FSB LGA775 UMart Online - Sunshine Coast (QLD) | www.umart.com.au | updated: 20-07-2011 $49.00Intel Celeron E3400 Wolfdale 2.6GHz 1MB L2 Cache LGA 775 65W Dual-Core Desk... iiBuy (NSW) | www.iibuy.com.au | updated: 20-07-2011 $50.00CPU/Processor Intel S775 Celeron Dual Core E3400 (2.4GHz) IT Estate (NSW) | www.itestate.com.au | updated: 20-07-2011 $50.82Intel Dual Core Celeron E3400 CPU, 2.60GHz/800MHz FSB/1MB cache/LGA775, Dua...ARC Computers (NSW) | www.arc.com.au | updated: 20-07-2011 $51.00Intel Dual Core Cel E3400 2.6G 1Mb; Dual Core Retail Box HS&F 800Mhz FSB; L... NetPlus (WA) | www.netplus.com.au | updated: 20-07-2011 $51.00Intel Dual Core Celeron E3400 CPU 2.60 GHz 800MHz FSB 1MB cache Socket LGA7...Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.00INTEL BX80571E3400 CELERON E3400 2.60GHz 1MB CACHE 800FSB LGA775Foxcomp Technology (WA) | www.foxcomp.com.au | updated: 20-07-2011 $51.11Intel Dual Core Celeron E3400 CPU, 2.60 GHz, 800MHz FSB, 1MB cache, Socket ...Excel Computers (NSW) | www.excelcomputers.com.au | updated: 17-07-2011 $52.75INTEL BX80571E3400 CELERON E3400/2.60GHZ/1MB CACHE/800 ...Computer Wholesale (NSW) | www.computerwholesale.com.au | updated: 15-07-2011 $52.95";
preg_match_all("/\\$[\d]+[\d\.]*/",$str,$matchs);
print_r($matchs);
?>
(
[0] => Array
(
[0] => $25.00
[1] => $39.00
[2] => $46.99
[3] => $47.00
[4] => $47.00
[5] => $48.00
[6] => $48.00
[7] => $48.00
[8] => $48.00
[9] => $48.93
[10] => $49.00
[11] => $49.00
[12] => $50.00
[13] => $50.82
[14] => $51.00
[15] => $51.00
[16] => $51.00
[17] => $51.11
[18] => $52.75
[19] => $52.95
))
print_r($matches[0]);