字符串拆分plzzzzzz帮我... [英] string splitting plzzzzzz help me...

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

问题描述

我有一个字符串

16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168


例如让我们说以上字符串

16:23:18.659343 - 时间

131.188.37.230 - srcaddress

22 --srcport

131.188.37.59 --destaddress

1398 --destport

tcp --protocol

168 --size

i需要拆分字符串,以便我需要获得所有这些

参数....

字段宽度不固定..我有一些四次/三位数

srcport ..所以我不能用substr函数做...我需要这个用c ++

i我不知道怎么拆分它..

感谢您的帮助

I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 -- srcaddress
22 --srcport
131.188.37.59 --destaddress
1398 --destport
tcp --protocol
168 --size
i need to split the string such that i need to get all these
parameters....
the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help

推荐答案

4月29日,4:24 * pm,xyz< lavanyaredd ... @ gmail.comwrote:
On Apr 29, 4:24*pm, xyz <lavanyaredd...@gmail.comwrote:

我有一个字符串

16:23:18.659343 131 .188.37.230.22 131.188.37.59.1398 tcp 168


例如让我们说上面的字符串

16:23:18.659343 - time

131.188.37.230 * - srcaddress

22 * * * * * * * * * * * * - srcport

131.188.37.59 * * - -destaddress

1398 * * * * * * * * * - destport

tcp * * * * * * * * * * - protocol

168 * * * * * * * * * - 大小

i需要分割字符串,这样我才能获得所有这些

参数....

*字段宽度不固定..我有一些四/三位数

srcport ..所以我不能用substr函数做...我需要这个在c ++

i我不知道如何分割它..

感谢您的帮助
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 * -- srcaddress
22 * * * * * * * * * * * *--srcport
131.188.37.59 * *--destaddress
1398 * * * * * * * * *--destport
tcp * * * * * * * * * *--protocol
168 * * * * * * * * *--size
i need to split the string such that i need to get all these
parameters....
*the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help



线索是''。''所以根据每个

字段读取你想要的功能...

the clue is ''.'' so read function as many you want according to each
field...


On 4月29日,1:24 * pm,xyz< lavanyaredd ... @ gmail.comwrote:
On Apr 29, 1:24*pm, xyz <lavanyaredd...@gmail.comwrote:

我有一个字符串

16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

i有这么多这样的行
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168
i have so many of such lines


例如让我们说上面的字符串

16:23:18.659343 - 时间

131.188.37.230 * - srcaddress

22 * * * * * * * * * * * * - srcport

131.188.37.59 * * - destaddress

1398 * * * * * * * * * - destport

tcp * * * * * * * * * * - protocol

168 * * * * * * * * * - 大小

i需要分割字符串,以便我需要获得所有这些

参数....

*字段宽度不固定..我有一些四/三位数

srcport ..所以我不能用substr函数...我需要这个在c ++中

i我不知道怎么拆分它..

谢谢你的帮助
for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 * -- srcaddress
22 * * * * * * * * * * * *--srcport
131.188.37.59 * *--destaddress
1398 * * * * * * * * *--destport
tcp * * * * * * * * * *--protocol
168 * * * * * * * * *--size
i need to split the string such that i need to get all these
parameters....
*the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help


4月29日下午2:24,xyz< lavanyaredd ... @ gmail.comwrote:
On Apr 29, 2:24 pm, xyz <lavanyaredd...@gmail.comwrote:

我有一个字符串

16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168


例如让我们说上面的字符串

16:23:18.659343 - 时间

131.188.37.230 - srcaddress

22 --srcport

131.188.37.59 --destaddress

1398 --destport

tcp --protocol

168 --size

i需要分割字符串,以便我需要获得所有这些

参数....

字段宽度不是固定..我有一些四/三位数

srcport ..所以我不能用substr函数...我需要这个在c ++
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 -- srcaddress
22 --srcport
131.188.37.59 --destaddress
1398 --destport
tcp --protocol
168 --size
i need to split the string such that i need to get all these
parameters....
the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++



然后在< news:comp.lang.c ++>中发布,因为它不是该组中的热门话题。

Then post in <news:comp.lang.c++>, as it is not topical in this group.


i我不知道如何分割它..
i am not getting an idea how to split it..



你可以从拆分空格开始。然后确定

分割标记中的哪一个是ipv4地址(你关心ipv6吗?)和

strrchr(str,''。'')

解决方案似乎很容易。我建议你在开始编写网络代码之前回去学习

基础知识。

You could start by splitting the spaces. Then determine which from the
splitted tokens are ipv4 addresses (do you care about ipv6?) and
strrchr(str, ''.'')
The solution seems very easy. I suggest you go back to learning the
basics before you start writing networking code.


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

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