?
Solved

Extracting Text from String Variable

Posted on 2011-03-23
3
Medium Priority
?
351 Views
Last Modified: 2012-05-11
Hi All,

I have the follwing URL stored within a string variable...

http://localhost:80/myfoldername

Using C#, how can I extract everything after the last '/' and store in a separate variable. In this example its 'myfoldername'? 'myfoldername' will vary in characters/size so the next time it could be called 'abcfolder' for example.

Thanks,

Rit
0
Comment
Question by:rito1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Assisted Solution

by:sshah254
sshah254 earned 800 total points
ID: 35202991
You should be able to use LastIndexOf and Substring.

Ss
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 1200 total points
ID: 35203149
string mystring = 'http://localhost:80/myfoldername';
string mynewstring = mystring.SubString(mystring.LastIndexOf('/')+1);
0
 
LVL 1

Author Closing Comment

by:rito1
ID: 35203169
Thanks both.

Rit
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question