Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn extract-links
- [matcher]
- (loop [rs []]
- (if-let [next (re-find matcher)]
- (recur (conj rs next))
- rs)))
- (defn decompose-link
- [link]
- (let [[_ url]
- (re-find (re-matcher #"href=[\'\"](.*)[\'\"]"
- (.replaceAll link " " "")))]
- [url (.replaceAll (re-matcher #"<.+?>" link) "")]))
- (defn array-links
- [desc]
- (let [matcher (re-matcher #"<a.+?</a>" desc)
- links (extract-links matcher)]
- (interleave (string/split
- (.replaceAll matcher "!!")
- #"!!") (map decompose-link links))))
- (array-links (str "A classic, <a href=\"foo\">1111111</a> wear-with-everything "
- "sweater with nautical-inspired anchor buttons at the "
- "neck. \n(We're also keeping it at the very top of our "
- "vacation <a href =\"bar\">22222</a> packing list, "
- "for plane rides or breezy beach nights.)"))
- (decompose-link (str "A classic, <a href=\"foo\">1111111</a> wear-with-everything "
- "sweater with nautical-inspired anchor buttons at the "
- "neck. \n(We're also keeping it at the very top of our "
- "vacation <a href=\"bar\">22222</a> packing list, "
- "for plane rides or breezy beach nights.)"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement