字符串验证/或某事...... [英] string validation/ or something...

查看:72
本文介绍了字符串验证/或某事......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我想是一个简单的问题。


我正在编写一个程序,从中获取信息文本文件并使用

来查询数据库的信息。听起来很简单.....


数据看起来像这样


[t_customers]

cust_ref = MOL01

cust_addr_1 = XYZ

Cust_Addr_2 = ABC

Cust_Addr_3 = LMN

Cust_Addr_4 = QRS
Cust_Addr_5 = DEF




我想做的是首先从表名中删除[],然后

其次在''='中将后续字符串分成两部分,因此

同时包含每个字段的字段名称和数据。


知道怎么管理这个吗?


干杯


P

Hi there,

Just a simple question, I think.

I''m writing a program that takes information from a text file and uses
that info to query a DB. Sounds simple enough.....

The data would look something like this

[t_customers]
cust_ref=MOL01
cust_addr_1=XYZ
Cust_Addr_2=ABC
Cust_Addr_3=LMN
Cust_Addr_4=QRS
Cust_Addr_5=DEF
etc

What I''d like to do is firstly remove the [] from the table name, and
secondly break the subsequent strings in two at the ''='' therefore
having both a field name and data for each field.

Any idea how I''d manage this?

Cheers

P

推荐答案

这可能会做你想要的,松散的。


昏暗的aVariant

做的不是你的文件对象.AtEndOfStream
aVariant = HandleLine(yourFileobject.ReadLine)

如果IsArray(aVariant)那么

''''用cust_addr_数据类型做你想做的事情

Response.Writ e aVariant(0)& "和 &安培; aVariant(1)

Else

Response.Write" Table name:" &安培; aVariant

结束如果

循环

函数HandleLine(行)

如果为Left(行&"" ;,1)=" ["然后

HandleLine =替换(替换(行,[,,"],],",

Else

HandleLine =拆分(行," =")

结束如果

结束功能

Ray在工作

" Ray Godfrey" <德***** @ yahoo.co.uk>在消息中写道

news:da ************************** @ posting.google.c om ...
This may do what you want, loosely.

Dim aVariant
Do While Not yourFileobject.AtEndOfStream
aVariant = HandleLine(yourFileobject.ReadLine)
If IsArray(aVariant) Then
''''do what you want with the cust_addr_ type of data
Response.Write aVariant(0) & " and " & aVariant(1)
Else
Response.Write "Table name: " & aVariant
End If
Loop
Function HandleLine(line)
If Left(line & " ",1) = "[" Then
HandleLine = Replace(Replace(line, "[", ""), "]", "")
Else
HandleLine = Split(line, "=")
End If
End Function
Ray at work
"Ray Godfrey" <de*****@yahoo.co.uk> wrote in message
news:da**************************@posting.google.c om...
你好,

我认为这只是一个简单的问题。

我正在编写一个从文本文件中获取信息的程序使用该信息来查询数据库。听起来很简单.....

数据看起来像这样

[t_customers]
cust_ref = MOL01
cust_addr_1 = XYZ
Cust_Addr_2 = ABC
Cust_Addr_3 = LMN
Cust_Addr_4 = QRS
Cust_Addr_5 = DEF


我想要做的是先删除从表名中选择[],然后在''='中将后续字符串分成两部分,因此
同时具有字段名称和每个字段的数据。
知道我是怎么做到这一点的吗?

P
Hi there,

Just a simple question, I think.

I''m writing a program that takes information from a text file and uses
that info to query a DB. Sounds simple enough.....

The data would look something like this

[t_customers]
cust_ref=MOL01
cust_addr_1=XYZ
Cust_Addr_2=ABC
Cust_Addr_3=LMN
Cust_Addr_4=QRS
Cust_Addr_5=DEF
etc

What I''d like to do is firstly remove the [] from the table name, and
secondly break the subsequent strings in two at the ''='' therefore
having both a field name and data for each field.

Any idea how I''d manage this?

Cheers

P





" Ray Godfrey" <德***** @ yahoo.co.uk>在消息中写道

news:da ************************** @ posting.google.c om ...

"Ray Godfrey" <de*****@yahoo.co.uk> wrote in message
news:da**************************@posting.google.c om...
你好,

我认为这只是一个简单的问题。

我正在编写一个从文本文件中获取信息的程序使用该信息来查询数据库。听起来很简单.....

数据看起来像这样

[t_customers]
cust_ref = MOL01
cust_addr_1 = XYZ
Cust_Addr_2 = ABC
Cust_Addr_3 = LMN
Cust_Addr_4 = QRS
Cust_Addr_5 = DEF


我想要做的是先删除来自表名的[]和



请参阅替换(...)VBScript函数。


其次打破'=''后面的两个后续字符串因此具有字段名称和每个字段的数据。



请参阅拆分(...)VBScript功能。


我知道如何管理它?

干杯

P
Hi there,

Just a simple question, I think.

I''m writing a program that takes information from a text file and uses
that info to query a DB. Sounds simple enough.....

The data would look something like this

[t_customers]
cust_ref=MOL01
cust_addr_1=XYZ
Cust_Addr_2=ABC
Cust_Addr_3=LMN
Cust_Addr_4=QRS
Cust_Addr_5=DEF
etc

What I''d like to do is firstly remove the [] from the table name, and

See the Replace(...) VBScript function.

secondly break the subsequent strings in two at the ''='' therefore
having both a field name and data for each field.

See the Split(...) VBScript function.


Any idea how I''d manage this?

Cheers

P





嘿雷,

感谢他们完美无缺的代码行。我的下一个问题

虽然是在从文件中取出信息之后转发信息,然后将
格式化为SQL插入表。所以....任何想法?备用更改?


P


***通过Developersdex发送 http://www.developersdex.com ***

Hey Ray,

Thanks for the few lines of code they work perfectly. My next problem
though is turning the information I''m after taking from the file and
formatting it into an SQL insert table. So....any ideas? Spare Change?

P

*** Sent via Developersdex http://www.developersdex.com ***


这篇关于字符串验证/或某事......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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