[C#] 3 best ways to remove all special characters from string

No comments
You want to remove characters \ /:*?"<>|!@#$%^&() from a string?
Very easy! Follow some method:

1. Remove all special characters
string rExp = "[^\w\d]";
string tmp = Regex.Replace(n, rExp, "");

2. Remove all special characters but allow some
Example: Allow . and _
Regex.Replace(input, "[^a-zA-Z0-9._]", string.Empty)

3. Easy function remove all special characters, but allow "_"

 public static string Remove_Special_Characters(string str)
        {
            StringBuilder sb = new StringBuilder();
            foreach (char c in str)
            {
                if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_')
                {
                    sb.Append(c);
                }
            }
            return sb.ToString();
        }

No comments :

Post a Comment

Debugging mode not can not work with F10 and F11 Visual Studio 2010

No comments
(Continue with fix-debugger-not-working)
When I going to debug with Visual Studio 2010, It work!
But when I want to run line by line at break point. I press F11 and F10... => It not work!!!

Solutions to fix:
1. Install http://support.microsoft.com/default.aspx/kb/957912
2. Change the port of the Visual Studio development server (go to menu Project > Properties > Web > *Server: User Visual Studio Development Server: Specific port = 12345)

No comments :

Post a Comment

What is benchmark?

1 comment
Today, more and more devices appear. Ext: more model smart phone, GPU, CPU, HardDisk,...

What's standard for all?
No! No standard for all, so more benchmark software appear. 

What is benchmark?

It's a software or a system for test or stress test  to compare performance of hardware, software or devices. Many developer using benmark software to improve or evaluate they products(hardware or software). Users using benchmark to compare products to buy best products.

Exp:
- Benchmark GPU to test speed, test temperature.
- Benchmark smartphone for battery life
- .... 

1 comment :

Post a Comment

What is “ops/sec”?

No comments
Today, my friend ask me: "What is ops/sec?"
:D

ops/sec is operations per second. When you test benmark. It's meanoften how many time execute a test in a second.

ops/sec often using for benchmark devices as smartphone, GPU, CPU, read write disk, or test for framework,...

Now you can answer "What is ops/sec?"!

No comments :

Post a Comment