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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:02:23+00:00 2026-05-24T05:02:23+00:00

I have a URL formatter in my application but the problem is that the

  • 0

I have a URL formatter in my application but the problem is that the customer wants to be able to enter special characters like:

: | / – “ ‘ & * # @

I have a string:

string myCrazyString  = ":|/-\“‘&*#@";

I have a function where another string is being passed:

public void CleanMyString(string myStr)
{
} 

How can I compare the string being passed “myStr” to “myCrazyString” and if “myStr has any of the characters in myCrazyString to remove it?

So if I pass to my function:

“this ‘ is a” cra@zy: me|ssage/ an-d I& want#to clea*n it”

It should return:

“this is a crazy message and I want to clean it”

How can I do this in my CleanMyString function?

  • 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-24T05:02:24+00:00Added an answer on May 24, 2026 at 5:02 am

    Use Regular Expression for that Like:

    pattern = @"(:|\||\/|\-|\\|\“|\‘|\&|\*|\#|\@)";
    
    System.Text.RegularExpressions.Regex.Replace(inputString, pattern, string.Empty);
    
    • split each string you want to remove by |
    • To remove the special characters like the | itself use \, so \| this will handle the | as normal character.

    Test:

    inputString = @"H\I t&he|r#e!";
    //output is: HI there!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a URL formatted like this: http://testsite1/mm/page1.php?tID=18&tSerial=TEST TT 1 And here is my
I have URL like: http://example.com#something , how do I remove #something , without causing
I have URL scheme for my blog like this: http://www.example.com/%YEAR%/%MONTH%/%CATEGORY%/%POST_TITLE%/ Now i want to
I have URL like this: http://localhost/PMApp/temp.htm?ProjectID=462 What I need to do is to get
I have url http://www.domain.com/folder/?variable=1 i would like to do a mod redirect to index.cfm
I currently have url like localhost/zend_practice/countries/index?data=1 where countries is the name of my controller
& is a reserved character in html therefore everywhere I have url's pointing to
I have a url of a type where query string is like this... ?
I have a url formatted like this: http://www.example.com/detail/state-1/county-2/street-3 What I'd like to do is
I have to post to a URL using PHP. right now it works but

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.