I have a huge HTML, but at a certain level there are 10 piece of article
element. I need theme.
<article class="box-product-big box-product-full clearfix" >
<div class="list-left">
<div class="cover">
<a id="book_cover_3100529" href="/film/fritz_lang.m-egy-varos-keresi-a-gyilkost-dvd.html">
<img src="http://s06.static.libri.hu/cover/d4/3/1090228_3.jpg" alt="Fritz Lang - M- Egy város keresi a gyilkost - DVD"/>
</a>
</div>
<div class="desc">
<a class="book-title" href="/film/fritz_lang.m-egy-varos-keresi-a-gyilkost-dvd.html">
..
</article>
Here is the relating DOM:
With the following pattern I try to get them, but zero piece returned:
var error: NSError?
let pattern = "<article class=\"box-product-big box-product-full clearfix\">[\\S\\s]*?</article>"
var regex = NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions.CaseInsensitive, error: &error)!
if error != nil {
println(error)
}
let a = regex.matchesInString(str, options: NSMatchingOptions.ReportCompletion, range: NSMakeRange(0, count(str)))
Any idea what is wrong?
Data comes from here: http://www.libri.hu/talalati_lista/?text=m
I tried with different escaping, but get an error:
String literals can include the following special characters: The escaped special characters \0 (null character), \ (backslash), \t (horizontal tab), \n (line feed), \r (carriage return), \" (double quote) and \' (single quote)
You are using a forward
/
which is a special character, so you have to escape it with a backslash using\/
:Quoting the documentation:
Btw, you can shorten your regex like this:
Code
Also, you can use capturing groups to capture the content: