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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:48:18+00:00 2026-05-20T07:48:18+00:00

If I have a string like: 10/10/12/12 I’m using: $string = ’10/10/12/12′; preg_match_all(‘/[0-9]+\/[0-9]+/’, $string,

  • 0

If I have a string like: 10/10/12/12

I’m using:

$string = '10/10/12/12';
preg_match_all('/[0-9]+\/[0-9]+/', $string, $results);

This only seems to match 10/10, and 12/12. I also want to match 10/12. Is it because after the 10/10 is matched that is removed from the picture? So after the first match it’ll only match things from /12/12?

If I want to match all 10/10, 10/12, 12/12, what should my regex look like? Thanks.

Edit: I did this

$arr = explode('/', $string);
$count = count($arr) - 1;
$newarr = array();
for ($i = 0; $i < $count; $i++)
{
    $newarr[] = $arr[$i].'/'.$arr[$i+1];
}
  • 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-20T07:48:19+00:00Added an answer on May 20, 2026 at 7:48 am

    I’d advise not using regular expression. Instead you could for example first split on slash using explode. Then iterate over the parts, checking for two consecutive parts which both consist of only digits.


    The reason why your regular expression doesn’t work is because the match consumes the characters it matches. Searching for the next match starts from just after where the previous match ended.

    If you really want to use regular expressions you can use a zero-width match such as a lookahead to avoid consuming the characters, and put a capturing match inside the lookahead.

    '#[0-9]+/(?=([0-9]+))#'
    

    See it working online: ideone

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

Sidebar

Related Questions

I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
I have string like this 0100110011001 I want to convert it to byte array
I have string like the following 'TextBoxKunde85_3_0', and i want to extract only the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
suppose I have string like this str1ng for test now i want to check
I have string like 123-123-1234 so I want to convert string into this format
I have a string like this: var tempSting:String = abc@abc.com;xyz@xyz.com I want to add
I have string like this: dog dog maddog Also I have following regex: [dog]*
i have string like this $string = 'aaaaaa, bbbbbb, cccccc, '; and i want

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.