[C#] 4 ways to remove "\r" or "\n" or "\t" new line or line break and tab characters from a string?
If you have a string, like this:
So you can using some methods:
Method 1: quick to code
string str = "Line 1\n Tab it.\t Break.\n'
How to remove breakline or tab in this string?
So you can using some methods:Method 1: quick to code
string newstr = Regex.Replace(str, @"\t|\n|\r", ""); // \t is tab, \n and \r is new line
Method 2: for New line onlystring newstr = str.Replace(Environment.NewLine, "");
Method 3: Easy to codestr = str.Replace("\n", String.Empty);
str = str.Replace("\r", String.Empty);
str = str.Replace("\t", String.Empty);
Method 4: For speed and low memory, because is StringBuilder best!var sb = new StringBuilder(s.Length);
foreach (char i in str)
if (i != '\n' && i != '\r' && i != '\t')
sb.Append(i);
str = sb.ToString();
12:21 AM
.Net
,
ASP
,
ASPX
,
C#
,
c# string
,
Special string
,
Visual Studio
4 methods to Install Gui For Centos 5 and Centos 6
If you want to install gui(GNOME) on your VPS to VNC connect you choose one method:
1. Oneline to install GUI for Centos 5, 6
Login as superuser and type:yum groupinstall "X Window System" "GNOME Desktop Environment"
You will download over 200MB to update.
2. Short oneline to install GUI for Centos
yum install @x11 @desktop3. Multiline to install destop for Centos
yum groupinstall -y 'X Window System'yum groupinstall -y 'Desktop'
yum groupinstall -y fonts
4. 4 step to install GUI and VNC
Step1: Install GUI on Centos:
yum -y groupinstall "Desktop"
Step2: Install VNC and firefox on Centos server:
yum -y install tigervnc-server xorg-x11-fonts-Type1 firefox
Step3: Then you start the VNC server on Centos
Run it as root:
vncserver
Step 4: Type the password and using VNC client to connect.
----------------
Note: If you want the GUI auto start on boot
Please type:
nano /etc/inittab
Change:
id:3:initdefault:
To:
id:5:initdefault:
To start the GUI for Centos manual, you type:
init 5
After that, you type:
startx
11:53 PM
centos
,
install GUI
,
Linux
,
remote destop
,
remote Linux
,
VNC sercer
,
vps
[C#] 3 best ways to remove all special characters from string
You want to remove characters \ /:*?"<>|!@#$%^&() from a string?
Very easy! Follow some method:
1. Remove all special characters
2. Remove all special characters but allow some
Example: Allow . and _
3. Easy function remove all special characters, but allow "_"
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(); }
11:12 AM
C#
,
c# string
,
Special string
Debugging mode not can not work with F10 and F11 Visual Studio 2010
(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)
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)
11:12 AM
.Net
,
ASPX
,
C#
,
debug
,
debugger
,
Visual Studio
,
Visual Studio 2010
What is benchmark?
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
- ....
What is “ops/sec”?
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?"!
: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?"!
5:03 AM
Benchmark
,
C#
,
Javascript
,
software
[ASP] Fix "Debugger not working - Authentication error occurred..."
Coding... coding... and press F5 to debug it...
The message show: "Debugger not working - Authentication error occurred while communicating with the web server" and you can't continue your work!
Some error similar
"Unable to start debugging on the web server. An authentication error occurred while communicating with the web server"
"Error while trying to run project. Unable to start debugging on the web server."
What problems?
Try check some one:
1. Are you register asp.net to IIS?
- Delete the ASPNET account
- Using commad line go to ASP.NET IIS Registration Tool and type "aspnet_regiis -i"
Read more at: http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx
2. If you using old system: IIS6, Visual Studio 2008,...
Please read this article: http://support.microsoft.com/kb/896861
The message show: "Debugger not working - Authentication error occurred while communicating with the web server" and you can't continue your work!
Some error similar
"Unable to start debugging on the web server. An authentication error occurred while communicating with the web server"
"Error while trying to run project. Unable to start debugging on the web server."
What problems?
Try check some one:
1. Are you register asp.net to IIS?
- Delete the ASPNET account
- Using commad line go to ASP.NET IIS Registration Tool and type "aspnet_regiis -i"
Read more at: http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx
2. If you using old system: IIS6, Visual Studio 2008,...
Please read this article: http://support.microsoft.com/kb/896861
Subscribe to:
Posts
(
Atom
)