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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:36:02+00:00 2026-06-17T22:36:02+00:00

Please forgive me if this question appears too cheap. I have this line: preg_match_all($pattern,

  • 0

Please forgive me if this question appears too cheap.

I have this line:

preg_match_all($pattern, $_GET['id'], $arr);

When you pass a value with space during a search, the value breaks once a space is encountered.

For instance:

36 2543541284

Notice a space between 6 and 2. In a situation similar to this, only 36 is displayed.

The reminder of digits after space are ignored. This is giving users, “no data found” message.

I have tried using urlencode to add 20% but no luck.

preg_match_all($pattern, rawurlencode($_GET[id]), $arr);

I have also tried urlencode but to no avail.

What am I possibly doing wrong?

function format($matches)
{
    return $matches[1][0].(strlen($matches[2][0])>0?$matches[2][0]:" ").$matches[3][0].(strlen($matches[4][0])>0?"  ".$matches[4][0]:"");
}

// CONSTRUCT A REGULAR EXPRESSION
$pattern
= '/'         // regex delimiter
. '('         // START of a capture group
. '\d{2}'     // exactly two digits
. ')'         // END of capture group
. '('         // START SECOND capture group
. '[ND]?'     // letters "D" OR "N" in any order or number - This is optional
. ')'         // END SECOND capture group
. '('         // START THIRD capture group
. '\d*'       // any number of digits
. ')'         // END THIRD capture group
. '('         // START FOURTH capture group
. 'GG'        // the letters "GG" EXACTLY
. '[\d]*'     // any number of digits
. ')'         // END THIRD capture group
. '?'         // make the LAST capture group OPTIONAL
. '/'         // regex delimiter
;


 preg_match_all($pattern, rawurlencode($_GET[id]), $arr);

// REFORMAT the array
$str = format($arr);

// show what we did to the data
echo '<pre>' . PHP_EOL;
echo '1...5...10...15...20...' . PHP_EOL;
echo $pattern;
echo PHP_EOL;
//Are we getting what we asked for? This is a test. We will comment out all 6 lines if we are happy with output of our REFORMATTING.
echo $str;
echo PHP_EOL;
  • 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-17T22:36:03+00:00Added an answer on June 17, 2026 at 10:36 pm

    Your regex as it stands will not match two digits followed by a space and further digits.
    If you want it to, you could change [ND]? to [\sND]?, although this would also allow a space if the string wasn’t all digits.

    You need to specify the rules precisely if you want further advice on the regex.

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

Sidebar

Related Questions

Please forgive me if this question is dense. Background: We have several internal applications
Please forgive this simplistic iphone development question. I have written a web application in
Please forgive the simplicity of this question. The answer will be obvious to many
Please forgive me if this is a silly question. We're running into a problem
This is probably a very simple question so please forgive my ignorance, but can
Please forgive me if this is an obvious one. I have an unknown amount
Please forgive if this question has been asked numerous times. I recently installed Eclipse
This is my first post, so please forgive me if this question has been
Could you please forgive me for eventual mistakes i can make asking this question
I'm new to Flash development so please forgive the simplicity of this question... I'm

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.