如何在delphi中分割字符串 [英] How to split the string in delphi

查看:134
本文介绍了如何在delphi中分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要将一个字符串分为:STANS,付款,chk#1,1210.000 到基于。字符串列表中的结果将是

I just need to split a string like: "STANS", "Payment, chk#1", ,1210.000 into an array based on ,. The result in the string list would be

STANS  
Payment, chk#1  

1210.000


推荐答案

创建一个 TStringList 并将逗号分隔的字符串分配给 StringList.CommaText 。这个解析输入并返回分割字符串作为字符串列表的项目。

Create a TStringList and assign your comma separated string to StringList.CommaText. This parses your input and returns the split strings as the items of the string list.

StringList.CommaText := '"STANS", "Payment, chk# 1", ,1210.000';
//StringList[0]='STANS'
//StringList[1]='Payment, chk# 1'
//etc.

这篇关于如何在delphi中分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆