简体   繁体   中英

Parsing a string using a delimiter to a TStringList, seems to also parse on spaces (Delphi)

I have a simple string which is delimited by some character, let's say a comma. I should be able to create a TStringList and set it's delimiter to a comma then set the DelimitedText to the text I want to parse and it should be automaticlly parsed.

The problem is when I look at the output it also includes spaces as delimiters and chops up my results. How can I avoid this, or is there a better way to do this.

There's a StrictDelimiter property on the TStringList. Set it to True and it will only parse on the delimiter, not the spaces.

That's standard, documented behavior of the TStrings.DelimitedText property. You want to set the StrictDelimiter property to true to disable that behavior.

如果您使用的是d7,可以查看“ExtractStrings”功能

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