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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:12:30+00:00 2026-06-09T12:12:30+00:00

I have a string with several unix statements, joined with (, ), ||, &&,

  • 0

I have a string with several unix statements, joined with (, ), ||, &&, |. I want to separate them out into arrays (nested?) in the order they would be evaluated in a unix command line. I preferably want them in a prefix notation, but anything would do.

like

a --foo "b|a||r" && a -b || (a || a) | c | d

should become

["|", ["|", ["||", ["&&", "a --foo \"b|a||r\"", "a -b"], ["||", "a", "a"]], "c"], "d"]

(Really tried to give an example that involves all possibilities.

How should I approach this?

I can understand code in most of the popular high level (OOP) languages (ruby, python, etc), or even a pseudocode would help.

  • 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-09T12:12:31+00:00Added an answer on June 9, 2026 at 12:12 pm

    If you think about it, the task is not different from parsing a mathematical expression, e.g. a * (b + c) / d ==> [/, [*, a, [+, b, c]], d] . Thus, you can use the same tools:

    You need is an infix parser.

    (Infix, because your operators are between the operands: e.g. a && b)

    Browse over the Wikipedia article for a bit of theoretical background, then grab an existing parser for the language you would like to use and define the operators as well as their precedence.

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

Sidebar

Related Questions

I have a several processes node.js. I want to only add one string to
I have to split a string into several ones. In fact what i need
lets say I have a string that I want to split based on several
I have an ASP.NET web app that places several string data into an object
I have a string containing several urls. I want to retrieve the urls containing
I have a string that with several parts separated by tabs: Hello\t2009-08-08\t1\t2009-08-09\t5\t2009-08-11\t15 I want
I have a string with several lines of CSS code. I want to match
I have a string which could contain several different values, among them are. EDITED
I have a string that has several date values in it, and I want
I have a situation where I need to concatenate several string to form an

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.