lianlianbushell 2013-01-23 05:45 采纳率: 0%
浏览 9458
已采纳

显示含有HTML标签的字符串

用谷歌API显示地图,然后有一些HTML方向字符串,包含了HTML标签。

现在我想在普通文本中显示这些字符,不知道应该怎么实现?字符串如下:

 Head <b>southwest</b> toward <b>GH Rd</b>
    Exit the roundabout onto <b>GH Rd</b><div style="font-size:0.9em">Go through 1 roundabout</div>
    At the roundabout, take the <b>1st</b> exit onto <b>Road Number 2</b><div style="font-size:0.9em">Pass by myonlinesearch.blogspot.com (on the left in 600&nbsp;m)</div>
    At the roundabout, take the <b>3rd</b> exit onto <b>CH Rd</b>
    At <b>Indroda Cir</b>, take the <b>2nd</b> exit onto <b>Gandhinagar Ahmedabad Rd/SH 71</b><div style="font-size:0.9em">Continue to follow Gandhinagar Ahmedabad Rd</div><div style="font-size:0.9em">Go through 1 roundabout</div>
    At the roundabout, take the <b>1st</b> exit onto <b>Sardar Patel Ring Rd</b>
    At <b>Ranasan Cir</b>, take the <b>3rd</b> exit onto <b>NH 8</b><div style="font-size:0.9em">Pass by Galaxy Restaurant (on the left in 4.3&nbsp;km)</div>
    Turn <b>left</b> onto <b>Galaxy Rd</b><div style="font-size:0.9em">Pass by Shiv Shakti Food Fort (on the left)</div>
    Turn <b>left</b> onto <b>NH 59</b>
    Turn <b>right</b><div style="font-size:0.9em">Go through 1 roundabout</div>
    Turn <b>right</b>
   Turn <b>left</b><div style="font-size:0.9em">Destination will be on the right</div>
  • 写回答

3条回答 默认 最新

  • vikeyToy 2013-01-23 06:14
    关注

    可以用RegularExpression/Predicates移除< & >内所有的内容

    不过如果文本也包含 <> 也会被移除

      NSRange range;
      NSString *string;
      while ((range = [string rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound){
        string=[string stringByReplacingCharactersInRange:range withString:@""];
      }
      NSLog(@"Un block string : %@",string);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程