Search

string trim end bug by Reynaldo Ferrer

Closed
as By Design Help for as By Design

2
2
Sign in
to vote
Type: Bug
ID: 776234
Opened: 1/10/2013 5:26:38 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Check this sequence used on immediate window:

"cebola.legal".TrimEnd(".legal".ToCharArray())
"cebo"
"cebola.legal".TrimEnd("legal".ToCharArray())
"cebola."
"cebola.legal".TrimEnd("\.legal".ToCharArray())
Unrecognized escape sequence
"cebola.legal".TrimEnd("..legal".ToCharArray())
"cebo"
"cebola.legal".TrimEnd("........legal".ToCharArray())
"cebo"
"cebola.legal".TrimEnd("........legalp".ToCharArray())
"cebo"
"cebola.legal".TrimEnd("........legalpato".ToCharArray())
"ceb"
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.0

Steps to reproduce

on a simple console, go to immediate window and repeat the sequence

"cebola.legal".TrimEnd(".legal".ToCharArray()) //expected : cebola

Product Language

English

Operating System

Windows 7 SP1

Operating System Language

Portuguese (Brazilian)

Actual results

"cebola.legal".TrimEnd(".legal".ToCharArray()) //expected : cebola, but we have a "cebo" string

"cebo"

Expected results

"cebola" string!
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/11/2013 at 12:10 PM
Hi Reynaldo Ferrer,

That's by-design. The trim APIs will remove any characters that passed via the char array -- order doesn't matter. You use String.Replace() if it doesn't matter where the string occurs. For most precise control you also use System.Text.Regex.

Regards,
Immo Landwerth
.NET Framework Team
Posted by Microsoft on 1/10/2013 at 9:00 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 1/10/2013 at 5:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.