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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:32:07+00:00 2026-06-08T18:32:07+00:00

I have been programming for one year and I have done string manipulation many

  • 0

I have been programming for one year and I have done string manipulation many times but never understood how it actually works or what the best way of doing it.

Let’s say I have this string

String abc = "https://uu2020.devuueva.com/portal/mesddsa/usforeer/nance/tings/M3C102d4104/1007/tingjack/default.aspx";

I want to only this part

"https://uu2020.devuueva.com/portal/mesddsa/usforeer/nance/tings/M3C102d4104"

Characters/Names can change and are dynamic, however “/” isn’t. Can someone demonstrate the simplest and the best way of doing it.

  • 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-08T18:32:08+00:00Added an answer on June 8, 2026 at 6:32 pm

    One thing to bear in mind here, is that if you’re dealing with a Uri, you are better off using the Uri class to extract pieces of information than trying to string-mash a solution together.

    http://msdn.microsoft.com/en-us/library/system.uri.aspx

    For example:

    var part = String.Format("{0}://{1}{2}",uri.Scheme,uri.Authority, String.Join("",uri.Segments.Take(7)));
    

    Gets the section you’re after. Live example: http://rextester.com/JRWKOG58567


    EDIT

    Having discovered some more requirement, and frameework limitation, you might be better string mashing this after all, but you can still leverage some functionality from the Uri class.

    var input = "https://uu2020.devuueva.com/portal/mesddsa/usforeer/nance/tings/M3C102d4104/1007/tingjack/default.aspx";
    var uri = new Uri(input);
    StringBuilder sb = new StringBuilder();
    sb.AppendFormat("{0}://{1}/",uri.Scheme,uri.Authority);
    
    var parts = uri.PathAndQuery.Split(new char[]{'/'},StringSplitOptions.RemoveEmptyEntries);
    for(var i=0;i<6;i++){
        sb.AppendFormat("/{0}",parts[i])   ;
    }
    Console.WriteLine(sb.ToString());
    

    Live example: http://rextester.com/HBK80648

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

Sidebar

Related Questions

I have been doing socket programming for many years, but I have never had
I have been programming in Delphi for a while, but I never ran across
I've been programming in Java for a little while now but have never really
I have been programming in Java for a while, but have never dealt with
I have been programming for Android with decent success, but one thing I have
I have been programming for some time, but I have some fundamental questions, one
I have been programming 10 years, mostly in vba and vb.net but I know
i have been programming for sometime but all of my programming books have not
I'm new to Android & Java programming but have been programming in .NET for
I've been programming Android in Eclipse for about a year now and I have

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.