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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:04:14+00:00 2026-06-09T00:04:14+00:00

I have a regex $pattern = ‘/\b\d{4}-\d{4}\b/’; preg_match($pattern, $text, $matches); I need to get

  • 0

I have a regex

$pattern = '/\b\d{4}-\d{4}\b/';
preg_match($pattern, $text, $matches);

I need to get the 5 words after that regex. Any ideas how I would accomplish this?

For example ” Power Slot Slotted Rotors – 1997-1998 Oldsmobile Regency – Brakes & Brake Pads – Brake Rotors.”

I need to return “1997-1998 Oldsmobile Regency – Brakes &”;

Any ideas?

// Update from the bottom comments.

There might be multiple matches in one string. For instance

“For example:”2000-2009 Ford Explorer, 2000-2010 Ford Ranger. 1674SJT JBA Cat4ward Headers Features”

I’m still trying to get the 1st 5 “non white spaces” after the number sequence xxxx-xxxx.

  • 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-09T00:04:17+00:00Added an answer on June 9, 2026 at 12:04 am

    Following your edits, try this:

    /\b\d{4}-\d{4}(?:\s(?!\d{4}-\d{4})\S+){1,5}\b/
    

    See it working

    With thanks to @Ariel for the regex this is based on, which was correct until additional requirements were specified through edits. If you like this, go upvote that answer as well 😉

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

Sidebar

Related Questions

I have a regex pattern that searches for words in a text file. How
I have a Regex pattern that matches data I need to parse exactly as
I currently have a regex pattern that matches a specific word, which includes arbitrary
I need to alter a RegEx pattern. I currently have this which matches all
I have got this regex pattern that works with my current apache log format:
Currently (in PHP) I have the following regex pattern: \[(.*) (.*)=(.*)\] This matches [doSomething
Is this actually doable? I have some very long regex pattern rules that are
I would like to have a RegEx that matches several of the same character
I have the following Regex-pattern: [A-TVWZ] . I need it to accept also Empty
I have a Regex that I now need to moved into C#. I'm getting

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.