c#中点的正则表达式 [英] Regular expression for points in c#

查看:95
本文介绍了c#中点的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我在c#表格中存储和检索数据库中varchar中的多个点。





我得到多个积分输入如

Please help me to store and retrieve points multiple points in a varchar in database in c# form.


I get multiple points as input like

X=30,Y=60
X=20,Y=40
X=70,Y=160



我必须将它们存储在数据库中并检索它们但是约束条件是我不会总是这3点积分可以是3点或4点或5点。 ..



因此从数据库中检索它们然后再转换为点



请帮忙解决这个问题


and I have to store them in database and retrieve them but the constraint is that I will not have always these 3 points the points can be 3 points or 4 points or 5 points...

Hence retrieve them from database and then convert to point again

Please help to solve this

推荐答案

正则表达式可以帮助解析一些字符串。所以,从这个问题来看,你看起来想要在数据库中存储一些字符串,并解析它们以获得包含一些数字数据的结构化数据。



这种方法是严重的,从根本上说是错误的。很难说出原因,但是现在许多初学者最常见的谬论之一是使用表示数据的字符串而不是数据本身的趋势。这对于数据库来说尤其典型。您需要将表示数据结构的基本类型元素存储在单独的表中,使用特定数据类型,数字表示数字数据,日期表示日期/时间数据等等。



使用结构数据和适当的设计需要理解关系模型,特别是规范化:

http://en.wikipedia.org/wiki/Normalization_%28database%29 [ ^ ],

http:// en.wikipedia.org/wiki/Relational_model [ ^ ]。



-SA
Regular expressions can help to parse some strings. So, from this question, it looks like you want to store some strings in database, and parse them to get some structured data which includes some numeric data.

This approach is badly, fundamentally wrong. It's hard to tell why, but one of the biggest common-place fallacies of many beginners these days is the trend to work with strings representing data, instead of data itself. This is especially typical for databases. You need to store elements of primitive types representing data structures in separate tables, using specific data types, numeric for numeric data, date for date/time data, and so on.

Working with structural data and appropriate design takes understanding of relational model, and, in particular, normalization:
http://en.wikipedia.org/wiki/Normalization_%28database%29[^],
http://en.wikipedia.org/wiki/Relational_model[^].

—SA


这篇关于c#中点的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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