Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2018
    Posts
    165
    Plugin Contributions
    4

    Default ereg to preg_match?

    I have an old plugin that I am updating and I see ereg which was replaced by preg_match in php7.

    Here is the code:

    PHP Code:
    if ( (!isset($_GET['sort'])) || (!ereg('[1-9][ad]'$_GET['sort'])) || (substr($_GET['sort'], 01) > sizeof($define_list)) ) { 
    Would it be changed to?

    PHP Code:
    if ( (!isset($_GET['sort'])) || (!preg_match('/[1-9][ad]'$_GET['sort'])) || (substr($_GET['sort'], 01) > sizeof($define_list)) ) { 

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: ereg to preg_match?

    Close! You'll want to add the ending delimiter, too:
    Code:
    if ( (!isset($_GET['sort'])) || (!preg_match('/[1-9][ad]/', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($define_list)) ) {

  3. #3
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: ereg to preg_match?

    you are missing a slash
    PHP Code:
    if ( (!isset($_GET['sort'])) || (!preg_match('/[1-9][ad]'$_GET['sort'])) || (substr($_GET['sort'], 01) > sizeof($define_list)) ) { 
    should be
    PHP Code:
    if ( (!isset($_GET['sort'])) || (!preg_match('/[1-9][ad]/'$_GET['sort'])) || (substr($_GET['sort'], 01) > sizeof($define_list)) ) { 

  4. #4
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,106
    Plugin Contributions
    11

    Default Re: ereg to preg_match?

    Great minds think alike By the timestamp, I note a virtual tie. We may need to go to the tape for the winner on this one.

 

 

Similar Threads

  1. preg_match(): Unknown modifier '0' ???
    By AnglersCorner in forum Upgrading to 1.5.x
    Replies: 5
    Last Post: 1 Jun 2015, 12:36 PM
  2. USPS Shipping Version: 2013-07-28 J - Preg_Match Warnings
    By jbible in forum Addon Shipping Modules
    Replies: 3
    Last Post: 29 Jul 2013, 09:28 PM
  3. preg_match() Unknown modifier 'a' warning in Admin Additiona Images addon
    By dlamar in forum All Other Contributions/Addons
    Replies: 6
    Last Post: 26 Mar 2010, 03:20 PM
  4. Fatal Error Call to undefined function: preg_match
    By droland in forum General Questions
    Replies: 3
    Last Post: 3 May 2008, 06:58 PM
  5. Warning: preg_match
    By pyewhacket in forum General Questions
    Replies: 6
    Last Post: 1 Sep 2007, 02:51 AM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR