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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:29:45+00:00 2026-05-14T06:29:45+00:00

I’m developing a REST service, so a request could be something like this: /Data/Main/Table=Customers/

  • 0

I’m developing a REST service, so a request could be something like this:

/Data/Main/Table=Customers/

I need to get the segments one by one, and for each segment I will decide wich object I’m going to use, after I’ll pass to that object the rest of the query so it can decide what to do next. Basically, the REST query is a path on a tree 😛

This imply lots String operations (depending on the query complexity), but StringBuilder is useful just for concatenations and remove, you cannot perform a search with IndexOf or similar.

I’ve developed this class that fulfill my requirement, but the problem is that is manipulating Strings, so every time I get one segment … I’ll create extra Strings because String is an inmutable data type:

public class RESTQueryParser
{
    String _query;

    public RESTQueryParser(String query)
    {
        _query = query;
    }

    public String GetNext()
    {
        String result = String.Empty;
        Int32 startPosition = _query.StartsWith("/", StringComparison.InvariantCultureIgnoreCase) ? 1 : 0;

        Int32 i = _query.IndexOf("/", startPosition, StringComparison.InvariantCultureIgnoreCase) - 1;

        if (!String.IsNullOrEmpty(_query))
        {
            if (i < 0)
            {
                result = _query.Substring(startPosition, _query.Length - 1);
                _query = String.Empty;
            }
            else
            {
                result = _query.Substring(startPosition, i);
                _query = _query.Remove(0, i + 1);
            }
        }

        return result;
    }
}

The server should support a lot of calls, and the queries could be huge, so this is gonna be a very repetitive task. I don’t really know how big is the impact on the memory and the performance, I’ve just readed about it in some books.

Should I implement a class that manage a Char[] instead Strings and implement the methods that I want? Or should be ok with this one? Regular expressions maybe?

UPDATE:

The above class is just a small aproximation, I’m still working on it and I have to parse more complex patterns.

I cannot use WCF REST or predefined paths (like map a regular expression to a specific method) because the query format can be changed by the user at runtime. So it has to be parsed step by step.

I cannot use String.Split, because for example a query could be : “Data/Search=’01/01/2008’/Whatever”.

  • 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-14T06:29:45+00:00Added an answer on May 14, 2026 at 6:29 am

    You might try a regular expression like this:

    var input = "/Data/Main/Table=Customers/";
    var regex = new Regex(@"\w+?/");
    var matches = regex.Matches(input);
    foreach (var match in matches)
    {
        Console.WriteLine(match.ToString());
    }
    Console.ReadKey();
    

    Also, you might look into the System.Web.Routing namespace…

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

Sidebar

Ask A Question

Stats

  • Questions 407k
  • Answers 408k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In short: class attributes cannot have doc strings in the… May 15, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer :g#\({\n\)\@<=#.,/}/sort Explanation: g " Work over the whole file running… May 15, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer The problem is that most trees cannot be validly reduced… May 15, 2026 at 6:39 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.