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

  • Home
  • SEARCH
  • 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 8114269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:06:05+00:00 2026-06-06T03:06:05+00:00

Following a protocol document, I can receive an array of parameters encoded as an

  • 0

Following a protocol document, I can receive an array of parameters encoded as an string in which each parameter is separated from others by a blank space. The spaces within parameters are escaped with backslashes.

So, let’s say we have the following strings within a parameter array:

array('Eli is beautiful', 'Fran is ugly', 'Oso is nice')

These will be encoded in just one string as follows:

Eli\ is\ beautiful Fran\ is\ ugly Oso\ is\ nice

Encoding is not a major problem, but I am facing problems with decoding.

I try to split parameters using a regular expression, that should splits by spaces that are not after a backslash, so this is my code:

$params = preg_split('/[^\\\\]\s/', $str);

It splits the params as expected, but it also removes the last char for each one, so this is the output of var_dump:

array(3) {
  [0]=>
  string(15) "Eli is beautifu"
  [1]=>
  string(11) "Fran is ugl"
  [2]=>
  string(11) "Oso is nice"
}
  • 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-06T03:06:06+00:00Added an answer on June 6, 2026 at 3:06 am

    Simply use negative lookbehind:

    $params = preg_split('/(?<!\\\\) /', $str);
    

    The regex above matches every space that is not preceded by a backslash, which is exactly what you intend.

    See it in action.

    Update: Your previous regex eats up letters because it matches the character preceding the space (as long as it’s not a backslash); therefore that character is considered part of the delimiter and removed from the output along with the space.

    The lookbehind version asserts that no backslash precedes the space, but does not match the character — an important difference.

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

Sidebar

Related Questions

I am developing a network protocol In which I have following requirement each node
I get the following error: Client does not support authentication protocol requested by server;
I have the following view controller in my UIPopover: @protocol StorePopoverDelegate - (void)storeSelected:(NSString *)store;
Following code produces a nested array as a result for keys containing three items:
The following is the example from the MSDN website example for JSON with bing
I'm trying to access an iframe contents from the document it is contained in,
I'm trying to replace each textNode of the DOM tree using the following function:
When I try to backup using mysqldump from ssh, I run the following command
I have the following XML document: <samlp:LogoutRequest ID=123456789 Version=2.0 IssueInstant=200904051217> <saml:NameID>@NOT_USED@</saml:NameID> <samlp:SessionIndex>abcdefg</samlp:SessionIndex> </samlp:LogoutRequest> I'd
I'm trying to extract UA-123456-7 from the following Google Analytic using regular expression. I

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.