Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 901453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:33:25+00:00 2026-05-15T15:33:25+00:00

I need to port some simple eregi regular expressions to preg_match for PHP 5.3/6.0

  • 0

I need to port some simple eregi regular expressions to preg_match for PHP 5.3/6.0 compilance.

Since I’m not too confident in my regular expression porting skills I need some help…

#1

Old version:

if( eregi('foo',$myVar) ) {
    $aresult = explode('/',stristr($myVar,'foo'));
    $aversion = explode(' ',$aresult[1]);
}

New version:

if( preg_match('/Foo\/([^ ]*)/i',$myVar,$matches) ) {
    $aversion = $matches[1];
}

#2

Old version:

if( eregi('bar',$myVar) && ! eregi('rv:[0-9]\.[0-9]\.[0-9]',$myVar)) {
    $aresult = explode('/',stristr($myVar,'bar'));
    $aversion = explode(' ',$aresult[1]);
}

New version:

//Not done yet need help
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:33:26+00:00Added an answer on May 15, 2026 at 3:33 pm

    Your second snippet is pretty much the same as the first, just with that extra condition. I’m going to guess that your actual code (or how you want it to work) is a little different to that presented? If so, could you elaborate on those differences please?

    Either way, your #2 could look similar to #1.

    if (preg_match('~bar/([^ ]*)~i', $myVar, $match) && ! preg_match('/rv:[0-9]\.[0-9]\.[0-9]/', $myVar)) {
        $aversion = $match[1];
    }
    

    The use of ~ as the delimiters might seem strange; the reasoning being that the regular expression contains the most usual delimiting character (/) so an alternative is used instead of escaping the slash as you did in the question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to build a COM DLL to do some simple serial port stuff.
I need to port some code from FreePascal to C. I'm a professional C
I'm trying to write some simple chat client in javascript, but I need a
I need to port the following from the ASP.NET MVC 2 sourcecode from C#
I need to port one of my old program to Windows. The current version
I have a win32 GUI (MFC) application which I need to port to a
I have a Django app that use a django-tagging. I need to port this
Hey can any one tell me should i need open a port for outgoing
I need to access COM port (console) via script to access our DSL modem.
I need to generate a random port number between 2000-65000 from a shell script.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.