Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 17-09-06
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
theaffiliatedrea is an unknown quantity at this point
  preg_match question

I am working on the trade doubler feed for dialaphone, it contains the field moreinfo which contains all none tradedoubler standard fields, for example
Quote:
Line Rental: 45.00; Manufacturer: Nokia; Tariff: Video, Talk&Text 1100 - 600 Xnet Mins 400 Texts; ContractMinTerm: 12; Network: Three; Model: MPN
I am trying to pull the Tariff using the following preg_match

PHP Code:
$str "Line Rental: 45.00; Manufacturer: Nokia; Tariff: Video, Talk&Text 1100 - 600  Xnet Mins 400 Texts; ContractMinTerm: 12; Network: Three; Model: MPN";

$do preg_match("/Tariff: (.*)(; [A-Z])/"$str$matches); 
This returns "Video, Talk&Text 1100 - 600 Xnet Mins 400 Texts; ContractMinTerm: 12; Network: Three"

This is happening as the reg ex is taking the last instance of "; [A-Z]" rather than the first.

Anyone know how this can be done?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 18-09-06
Registered User
 
Join Date: Mar 2004
Location: Reading, UK
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
dmorison is an unknown quantity at this point
Hi,

That's happening because Perl regular expressions are "Greedy" by default - they try to match as much text as possible within the rules. You can make your expression "Ungreedy" by adding the "U" qualifier to the end, so the following code should work as required:

PHP Code:
$str "Line Rental: 45.00; Manufacturer: Nokia; Tariff: Video, Talk&Text 1100 - 600  Xnet Mins 400 Texts; ContractMinTerm: 12; Network: Three; Model: MPN";

$do preg_match("/Tariff: (.*)(; [A-Z])/U"$str$matches); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
search engine question? paulmacd The Affiliate Marketing Lounge 6 01-04-06 02:33 AM
Question about Adsense Paulus The Affiliate Marketing Lounge 7 13-02-06 02:53 PM
ok may be a dumb question regardinf affiliate managers justhomdotcom The Affiliate Marketing Lounge 8 06-12-05 12:59 PM
Merchant question: more than 1 network justhomdotcom The Affiliate Marketing Lounge 7 03-08-05 05:15 PM
New member question - Shop directories dave21 The Affiliate Marketing Lounge 9 11-03-05 01:18 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7