简体   繁体   中英

Remove Last and begin specific character from String

I want to remove a specific character from the end and the beginning of string.

Example:

  • Input ==> Maro; Output should be Maro
  • Input ==> Maro Output should be Maro
  • Input ==> Maro;Mike; output should be Maro;Mike
  • Input ==> ;Maro;Mike output should be Maro;Mike
  • Input ==> ;Maro;Mike;Tim; output should be Maro;Mike;Tim

Any idea

string s = ";Maro;Mike;Tim;";
string s2 = s.Trim(';');

尝试这个:

input.Trim(";".ToCharArray())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM