Solved

Extracting Text from String Variable

Posted on 2011-03-23
3
309 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
3 Comments
 
LVL 9

Assisted Solution

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

Ss
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 300 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Round up to 100% in .NET 10 44
Asp.net mvc entity issue 6 19
fomat Json objects 6 17
Cannot upload files above 1mb IIS7 11 12
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now