Parsing a string using a delimiter to a TStringLis

2019-04-29 07:15发布

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.

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-04-29 07:30

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

查看更多
Evening l夕情丶
3楼-- · 2019-04-29 07:35

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

查看更多
走好不送
4楼-- · 2019-04-29 07:43

You can have a look on the function "ExtractStrings" , if you are using d7

查看更多
登录 后发表回答