Results 1 to 3 of 3

 

Thread: Simple preg_match - or should be!

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Sep 2003
    Posts
    315
    Thanks
    28
    Thanked 19 Times in 16 Posts


    Hi

    I'm struggling to do something very simple with regular expressions and preg_match.

    I have: BRAND MODEL

    Something like: Sony A1B2

    I want to extract just the model, so the reg ex I need is 'a complete word containing both letters and numbers'.

    Here's what I thought should work:

    preg_match("/[a-zA-Z0-9]+/", $product_name);

    But that brings back Sony. Any help very much appreciated.

    Thanks

    Tom

  2. #2
    scriptmonkey's Avatar
    Oranges & Lemons

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Worthing
    Posts
    1,607
    Thanks
    112
    Thanked 253 Times in 192 Posts
    Tom, put a space in, because there's a space between your brand and model:

    preg_match('/ [a-z0-9]+/i', $product_name);

    Added the i to make it case-insensitive.

    Tony
    The trouble with the rat race is that even if you win you're still a rat.
    Time passes. Listen. Time passes. Dylan Thomas
    Ebay Alerts to your inbox

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    These questions have raised the concept of web statistics. Often times, webmasters use certain programs, such as Google Analytics or Awstats, to complete this job for them. These programs obtain a wide variety of information about visitors to a site. They find page views, visits, unique visitors, browsers, IP addresses, and much more. But how exactly is this accomplished? Follow along as we present a tutorial on how to create your own web statistics program using PHP, JavaScript, AJAX, and SQLite.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2