Parsing HTML NSRegularExpression

佐手、 提交于 2019-12-01 14:29:08

Try using this regex:

 @"<div class=\"fact\" id=\"fact[0-9]*\">([^<]*)</div>"

Regex:

fact[0-9].*

means: fact followed by a number between 0 and 9, followed by any character repeated any number of times.

I also suggest using:

([^<]*)

instead of

(.*)

to match between the two divs so to deal with regex greediness, or alternatively:

(.*?)

(? will make the regex non-greedy, so it stops at the first instance of </div>.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!