Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hello, I want to remove certain characters from a string. Say the input looks like this:
C#
string ss="website15(3)\\.net(5)";
But I want it to look like
website15\\.net
What options do I have available to me?
Posted
Updated 14-May-12 2:00am
v2
Comments
Sandeep Mewara 14-May-12 7:55am    
Try to remove/ignore "(number)" using Regex.
Prasad_Kulkarni 14-May-12 7:56am    
You already asked this question: How to remove between those character using C#.net[^]

Why a re-post?
If you're not getting proper answer then add comments at respective answers using 'Submit Comment' widget. Don't report your questions.
Sandeep Mewara 14-May-12 8:00am    
Just found... it's a REPOST!

 
Share this answer
 
Effectively you face two choices:

1. Use string indexes to find the position of the first ( and then use that to find the ) that follows it (use the index of the first ( as the starting position for your search). Now that you have the indexes, you would use substring to retrieve the part up to the (, and then from the ) to the end. Repeat this process until you have no more ( ) sequences.

2. Use a regular expression to search for the (...) parts, and replace them with an empty string.

When I'm writing and testing regular expressions, I use Expresso[^] to help me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900