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 8368177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:19:34+00:00 2026-06-09T13:19:34+00:00

I have the following code: <?php $data=000ffe-fcc9f4 1 000fbe-fccabe; $pattern=’/([0-9A-F]{6})-([0-9A-F]{6})$/i’; echo the pattern we

  • 0

I have the following code:

 <?php
        $data="000ffe-fcc9f4 1 000fbe-fccabe";
        $pattern='/([0-9A-F]{6})-([0-9A-F]{6})$/i';
        echo "the pattern we are using is: ".$pattern."<BR>";

        preg_match_all($pattern,$data,$matches, PREG_SET_ORDER );

        print_r($matches[0]);

?>

I don’t understand why it’s not finding both mac addresses as matches.

Here’s what the output on the page looks like:

the pattern we are using is: /([0-9A-F]{6})-([0-9A-F]{6})$/i
Array ( [0] => 000fbe-fccabe [1] => 000fbe [2] => fccabe ) 

I was expecting that element [0] would contain both 000ffe-fcc9f4 and 000fbe-fccabe.
Can you tell me what I’m doing wrong?

Thanks.

  • 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-06-09T13:19:35+00:00Added an answer on June 9, 2026 at 1:19 pm

    The reason it isn’t finding both is because you have a $ at the end of your regex which means it will only match that pattern at the end of the string.

    Try changing $pattern to /([0-9A-F]{6})-([0-9A-F]{6})/i and that should match both.

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

Sidebar

Related Questions

I have the following code <a href=# class=chosenflag data-flag=<?php echo $lang;?>><img class=flag src=/img/flag/United Kingdom.png
I have the following code: $.ajax({ async: false, url: 'chart_data.php', data: {'option':'high', 'id':id}, dataType:
I have the following code: $(document).ready(function(){ $.ajax({ url: svc/GetTweetsByUser.php, type: POST, success: function(data) {
I have the following code: $.ajax({ type: 'GET', url: 'edit_slides.php', data: { user_id: user_id
I have the following code in php: <?php $con = mysql_connect(localhost,john,john); mysql_select_db(data, $con); if
I have the following code which orders my data in mysql perfectly: <?php $con
I have the following code: <?php if (!$user) { ?> <div class=fb-login-button data-perms=email,user_birthday,publish_stream>Login with
I have the following code: <?php $FILE=giant-data-barf.txt; $fp = fopen($FILE,'r'); //read everything into data
I have following PHP code for inserting session data into a table called ds_session:
In my cakephp form I have following code <p> <?php echo $form->input('option[]',array('size'=>13)); ?> </p>

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.