| |

VerySource

 Forgot password?
 Register
Search
View: 820|Reply: 8

How to remove the space and TAB after the string

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-1 18:30:01
| Show all posts |Read mode
Excuse me, how to remove the space and TAB key after the string (Note, there may not be only one space and TAB key after each string)
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-5-12 00:00:02
| Show all posts
split or regex
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-12 12:00:02
| Show all posts
string temp = "asdf";
string re = temp.Trim ();
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-18 16:45:01
| Show all posts
Use regular expressions to remove white space characters (including spaces, carriage returns, tabs) in the string

Quote
using System.Text.RegulrExpression;

Regex regex = new Regex ("\\s +");
string str = regex.Replace (textbox1.text, "");

Disadvantages: The spaces in the string will also be processed.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-5-19 21:15:01
| Show all posts
This is not possible. I just want to remove the trailing spaces and TAB
Also. Do you know how to save the string in one file to another file?
I use streamread and streamwriter
Thank you
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-21 08:45:01
| Show all posts
string.TrimEnd ('', '\t')
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-22 10:45:01
| Show all posts
string.Trim ();
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-23 23:45:01
| Show all posts
FT】
Direct string.TrimEnd (); not OK? !
Reply

Use magic Report

0

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-5-25 01:00:01
| Show all posts
Just use string.TrimEnd (), not so troublesome
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list