...
  • Conception de systèmes informatiques et servi" /> ...
  • Conception de systèmes informatiques et servi" /> ...
  • Conception de systèmes informatiques et servi"/>

    Clojure Enlive: A selector that uses regex

    260 Views Asked by At

    I'm trying to select the :li node that has, in is content, the word "(SCIAN":

    <li>...</li>
    <li class="">
                    Conception de systèmes informatiques et services connexes (SCIAN 541510)
                </li>
    
    <li>...</li>
    

    I've fail trying this:

    (html/select
        fetched
        [[:li (html/has [(html/re-pred #"\w*SCIAN\b")])]])))
    

    Thank you for your help!

    Notice: I've tried use these patterns without success so I might do something wrong: https://groups.google.com/forum/#!topic/enlive-clj/thlhc5zBRUw

    2

    There are 2 best solutions below

    2
    Joe Lehmann On

    I think the regex in combination with french accents causes the problem:

        (def s "è")
        (def r #"\w") 
        (re-matches r s)
        ;;; => nil
        (def s "e")
        (re-matches r s)
        ;;; => "e"
    
    0
    leontalbot On

    To make that work, we actually don't need to use regex:

    (html/select
        fetched
        [[:li (html/pred #(.contains (html/text %) "SCIAN"))]])