文本框中的拆分字符串

文本框中的拆分字符串

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

问题描述




我有TxtLastName,TxtFirstName和TxtMiddleName作为文本框。

但在我的数据库中,记录是Roa,Paul Vista。



如何SPLIT到三个文本框(TxtLastName.text,TxtFirstName.text和TxtMiddleName.text)



谢谢&问候,

PaulAndrewRoa

Hi
I have TxtLastName, TxtFirstName and TxtMiddleName as text boxes.
But in my database the record is Roa, Paul Vista.

how to SPLIT to THREE TEXT BOXES (TxtLastName.text, TxtFirstName.text and TxtMiddleName.text)

Thanks & Regards,
PaulAndrewRoa

推荐答案

string surnameExtractionArray = Split(completeString, ',');



,根据您在问题中所说的内容,应该返回一个2元素数组。



元素1 =姓氏。



元素2 =字符串的其余部分。



然后我们可以合理地猜测第一个单词是名字。




this, based on what you have said in your question should return an 2 element array.

Element 1 = last name.

Element 2 = the rest of the string.

Then we can make a reasonable guess that the first word is the first name.

string firstName = surnameExtractionArray[1].Trim().Split(',')[0];
string middleNames = surnamExtractionArray[1].Replace(firstName).Trim()





这可能不是最有效的方法,但它应该做你需要的。



This probably isn't the most efficient way of doing this, but it should do what you need.



这篇关于文本框中的拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:45