Need your help how to extract more than one similar string from one string using Regex in Perl
This is source string :
Sat Feb 16 23:56:30 ICT 2013 - wulan321~ sw dadan complain cant acces internet HP : Samsung galaxy S3 offer : Offer and VAS Active Type Active Since Expiry Date Remaining More AO_MDS_PDMA_Pre/Post_Data500MB_30D Regular SOC 2/16/2013 4:19:29 PM 0 AO_MDS_PDMA_Pre/Post_Data500MB_30D AO_MDS_PDMA_Pre/Post_Data1.2GB_30D Regular SOC 2/16/2013 11:47:05 PM 0 AO_MDS_PDMA_Pre/Post_Data1.2GB_30D CM : reff gpnblo apn : intern et username : dikosongkan paswword : dikosongkan done
My output expectation is :
AO_MDS_PDMA_Pre/Post_Data500MB_30D 2/16/2013 4:19:29 PM
AO_MDS_PDMA_Pre/Post_Data1.2GB_30D 2/16/2013 11:47:05 PM
I already done some works with perl :
if ($string =~ /([Additional.*|A ?O.*])+(AO_.+?)+[\t*?| *?]Regular SOC[\t*?| *?](.+?[A|P] ?M)/)
{
print "$2 $3\n";
}
But the output only captured the first occur string:
AO_MDS_PDMA_Pre/Post_Data500MB_30D 2/16/2013 4:19:29 PM
Looking forward for the guidance guys
Try a loop and the g
flag:
while ($string =~ /REGEX-HERE/g)
{
print "$2 $3\n";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.