如何只返回输入文本框的文本/字符串中的单词,符号,数字? [英] How Do I return only words, symbols, numbers from text/string entered into a textbox?

查看:78
本文介绍了如何只返回输入文本框的文本/字符串中的单词,符号,数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多行文本框,用于输入用户输入的单词,然后是一个按钮事件存根,用于将键入的文本框中的字符串返回到另外三个单独的文本框中,其中第一个文本框仅显示字符串中的单词,第二个只显示字符串中的数字,第三个只显示字符串中的符号。



我知道IndexOf()函数,但是在字符串操作方面我从来没有运气。

解决方案

正如Hiren2所说,你可以迭代这些角色。然后你可以使用Char类的方法来确定每个类型的字符。



GetUnicodeCategory(String,Int32)



http://msdn.microsoft。 com / en-us / library / system.char(v = vs.110).aspx [ ^ ]


你想要做的事可能根本就没有意义。如果您允许输入自由文本,则与语义文本分析的大部分未解决问题有关。如果这是一组固定数据元素,那么每个字段具有不同的控制权,或者使用某些多字段控制(例如网格视图或属性网格)会更好。

-SA

I have a multi line textbox that takes in words entered by a user, and then a button event stub to return the string typed into the text box, in three other separate textboxes, where the first textbox displays only words in the string, the second displays only numbers in the string and the third displays only symbols in the string.

I'm aware of the IndexOf() function, but I've never had any luck with it when it comes to string manipulation.

解决方案

As Hiren2 says, you can iterate the characters. Then you can use the Methods of the Char class to determine which type of character each is.

GetUnicodeCategory(String, Int32)

http://msdn.microsoft.com/en-us/library/system.char(v=vs.110).aspx[^]


What you are trying to do may simply make no sense. If you allow entering free text, it would be related to mostly unsolved problem of semantic text analysis. If this a set of fixed data element, you would be much better off having different control per each field, or using some multiple-field control, such as a grid view or a property grid.
—SA


这篇关于如何只返回输入文本框的文本/字符串中的单词,符号,数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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