Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have a list like

list = {"my element 1", " my element 2"}

how do I get a list of the links inside each element?

Something like

StringCases[list, "http" ~~ _]

probably but I wasn't able to know how to end my pattern.

share|improve this question
Yet another way, Select[StringSplit[#], StringMatchQ[#, "http://*"] &] & /@ list. Sorry about the nested Function. – Szabolcs Oct 22 '13 at 15:01
@Szabolcs go answer! – Yves Klett Oct 22 '13 at 17:21
up vote 9 down vote accepted

One way:

StringCases[list, "http://" ~~ Except[WhitespaceCharacter] ..]

{{""}, {""}}

share|improve this answer
that's great but I don't see what the pattern ".." does in the documentation? – Sulli Oct 21 '13 at 12:22
@su1 Look up Repeated, a good friend on many a jolly pattern matching occasion :-) – Yves Klett Oct 21 '13 at 12:24

Another way, similar to @YvesKlett, but with RegularExpression.

StringCases[list, RegularExpression["http://\\S+"]]

{{""}, {""}}

In RegularsExpression \\S means non space characters. You can find more information in Wolfram documentations here

share|improve this answer
You could give a short description of your regex to make it even more educational ;-) – Yves Klett Oct 22 '13 at 14:06
@YvesKlett Agree. Done! – Murta Oct 22 '13 at 20:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.