regex - iOS Regular Expression Understanding -
recently use nsregularexpression me parse website's source.
i found example expression @"(.*?)(<[^>]+>|\\z)". kind people me out meaning of pattern?
(.*?)(<[^>]+>|\z) - first part (.*?) non-greedy way of consuming characters, or in other words, consume minimum possible number of characters until reach next part: (<[^>]+>|\z).
(<[^>]+>|\z) - here have 2 parts, first part <[^>]+> - match expression starts < , has @ least 1 character before closing >. [^>] means character except > , + means number of characters >= 1.
the | "or" - means matching group should match either first part <[^>]+> or second part \z means end of string.
Comments
Post a Comment