从字符串中删除标签 - [英] Remove tags from string -
问题描述
大家好,我有一个c ++程序,它从雅虎财经中检索给定股票代码的JSON格式的股票信息,其中一个字段的最后交易值嵌入在粗体标记中 - 任何人都知道删除标记的方法?我用谷歌搜索了,我发现的所有方法似乎都涉及外部库,所有这些都是我的需求过度杀戮(该程序只是为了我的娱乐,看着我的股票在公投后走下坡路:-))违规行显示下面
Hello all, I have a c++ program which retrieves stock information in JSON format from yahoo finance for a given stock symbol, one of the fields has the last trade value embedded in a bold tag - anyone know a way of removing the tag ? I've googled and all the methods I've found seem to involve external libraries all of which are overkill for my needs ( the program is only for my amusement watching my shares go downhill following the referendum :-) ) The offending line is shown below
LastTradeWithTime: 4 : 00pm - "<b>699.21</b>"
我的尝试:
谷歌搜索并在这里询问一些帮助
What I have tried:
Googling and asking here for some assistance
推荐答案
你可以使用正则表达式:
使用
You could use a Regex:
Use
</?b>
作为匹配字符串,并使用Regex.Replace将其替换为空字符串。
As the match string, and use Regex.Replace to replace it with an empty string.
如果您确定字符串遵循此类字符串您可以使用的固定格式 string :: substr
(请参阅 string :: substr - C ++参考a> [ ^ ])而不是。
If you're sure the strings follow such a fixed format you may use string::substr
(see string::substr - C++ Reference[^]) instead.
这篇关于从字符串中删除标签 - 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!