如何从c中的行打印特定单词 [英] how to print particular words from line in c

查看:103
本文介绍了如何从c中的行打印特定单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从socket完整的html代码中获取数据。

使用解析我使用令牌将其拆分为行我们打印完整行

如果使用strstr与任何标签我也得到标签写的全线

i只想要该行的特定单词

就像我得到了回复...

< pre lang =HTML> < a href = Account / Login.aspx id = HeadLoginView_HeadLoginStatus > 登录< / a >



我想只打印

登录



我该怎么做。

 A =   a herf 

if (strstr(token,A)!= NULL)
{
printf(%s \ n,token);

}

解决方案

有几种选择(按需提升的顺序排序):

  1. 使用库解析 XML 内容(其中有几个免费提供)。
  2. 使用正则表达式。同样有几个可用的库提供正则表达式。
  3. 自己努力解析 XML 内容,即构建一个perser,可能是定制的广告根据您的要求。


I get data from socket full html code.
using parsing i split it into line using token via that we print full line
if use "strstr" with any tag i also get full line where tha tag was written
i want only particular words from that line
like i got response...

<  a href="Account/Login.aspx" id="HeadLoginView_HeadLoginStatus">Log In  < /a >


and i want to print only
""Log in""

How can i do it.

A= "a herf"

if(strstr(token,A) !=NULL)
{
printf(%s\n,token);

}

解决方案

There are several options (ordered by ascending effort required):

  1. Use a library for parsing XML content (there are several of them available for free).
  2. Use regular expressions. Again there are several available libraries providing regular expressions.
  3. Do yourself the hard work of parsing the XML content, that is build a perser, possibly tailored ad hoc for your requirements.


这篇关于如何从c中的行打印特定单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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