从字符串中提取数字 [英] Extracting numbers from a string

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

问题描述

我有很多代表时间的字符串。


1w 2d 3h 15m

2d 3h 15m

4h 30m

45m


我想将字符串的数字部分提取为单独的

变量,包括周,天,小时和分钟。


任何团体对如何做到这一点有什么好主意?

I have a number of strings that represents time.

1w 2d 3h 15m
2d 3h 15m
4h 30m
45m

I want to extract the number parts of my strings into separate
variables for Weeks, Days, Hours and Minutes.

Any body got any good ideas about how to do this?

推荐答案

"丹" < da ********** @ newcross-nursing.comschrieb
"Dan" <da**********@newcross-nursing.comschrieb

我有很多代表时间的字符串。


1w 2d 3h 15m

2d 3h 15m

4h 30m

45m


我想将我的字符串的数字部分提取为单独的

变量,包括周,天,小时和分钟。


任何身体都有任何好处关于如何做到这一点的想法?
I have a number of strings that represents time.

1w 2d 3h 15m
2d 3h 15m
4h 30m
45m

I want to extract the number parts of my strings into separate
variables for Weeks, Days, Hours and Minutes.

Any body got any good ideas about how to do this?


http: //msdn2.microsoft.com/en-us/library/st9zk29t.aspx

Armin


http://msdn2.microsoft.com/en-us/library/st9zk29t.aspx
Armin


" ;丹" < da ********** @ newcross-nursing.comwrote in message

news:11 ****************** ****@o80g2000hse.googlegr oups.com ...
"Dan" <da**********@newcross-nursing.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...

>我有许多表示时间的字符串。


1w 2d 3h 15m

2d 3h 15m

4h 30m

45m


我想将我的字符串的数字部分提取为单独的

变量,包括周,天,小时和分钟。


任何机构对如何获得任何好的想法这样做?
>I have a number of strings that represents time.

1w 2d 3h 15m
2d 3h 15m
4h 30m
45m

I want to extract the number parts of my strings into separate
variables for Weeks, Days, Hours and Minutes.

Any body got any good ideas about how to do this?



空气代码:

string.Split方法可以让你构建每一行的数组,例如myArray

= sLine.split("")

您可以使用string.Contains方法来确定它是否是一周工作时间



也许用于存储数据行的Stuctures数组......

只是一些想法.....

Air code:
The string.Split method will let you build an array of each line eg myArray
= sLine.split(" ")
You could use the string.Contains method to identify if it is a week hour
etc
Perhaps an array of Stuctures to store the rows of data in...
Just a couple of ideas.....

我会查看正则表达式。


好​​Luc k,Bob


" Dan" < da ********** @ newcross-nursing.comwrote in message

news:11 ****************** ****@o80g2000hse.googlegr oups.com ...
I''d look into regular expressions.

Good Luck, Bob

"Dan" <da**********@newcross-nursing.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...

>我有许多表示时间的字符串。


1w 2d 3h 15m

2d 3h 15m

4h 30m

45m


我想将我的字符串的数字部分提取为单独的

变量,包括周,天,小时和分钟。


任何机构对如何获得任何好的想法这样做?
>I have a number of strings that represents time.

1w 2d 3h 15m
2d 3h 15m
4h 30m
45m

I want to extract the number parts of my strings into separate
variables for Weeks, Days, Hours and Minutes.

Any body got any good ideas about how to do this?



这篇关于从字符串中提取数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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