Parsing HTML NSRegularExpression

后端 未结 1 1061
逝去的感伤
逝去的感伤 2021-01-17 02:43

i\'m trying to parse an HTML page using NSRegularExpressions.. The page is a repetition of this html code:

STRING THA
1条回答
  •  粉色の甜心
    2021-01-17 03:04

    Try using this regex:

     @"
    ([^<]*)
    "

    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

    .

0 讨论(0)
提交回复
热议问题