Message Boards Message Boards

0
|
8371 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to extract elements that interest me in this list?

Posted 10 years ago

Hi all I would like to help me to do the following, I have following list :

prb = {{"https://www.youtube.com/watch?v=SGfM-JEEBvs"}, \
{"http://www.dma.fi.upm.es/docencia/segundociclo/geomfrac/proyectos/\
tutorial-mov-brow/Pagina%20Inicio.htm"}, \
{"http://tierrafertil.com.mx/otorgan-galardon-internacional-\
investigador-de-chapingo/"},  {"https://www.youtube.com/watch?v=KO3X7udtZKI"}, \
    {"https://www.youtube.com/watch?v=2FhchwKHt00"}, \
    {"https://www.youtube.com/watch?v=3lgh0RuJWnM"}, \
    {"https://www.youtube.com/watch?v=Ct3dabOl9aA"}, \
    {"https://www.youtube.com/watch?v=Hyc8XmRDwPY"}, \
    {"http://community.wolfram.com/dashboard"}, \
    {"http://blogsocl.com/segun-experto-asi-luce-el-cuerpo-\
    cientificamente-perfecto-de-una-mujer-su-nombre-es-kelly-brook/#"}, , \
    {"http://blog.linuxmint.com/"}, \
    {"https://www.youtube.com/watch?v=5EpoIbj-i2o"}, \
    {"https://www.youtube.com/watch?v=wZ969VcRTH0"}};

and I want to get in a single list all what start with "http://www.youtube something"

Thanks in advance, I hope that someone can help me because the original list contains about 300 elements too which complicates the task.

POSTED BY: Luis Ledesma
5 Replies
Posted 10 years ago

Remove the extra comma you have between two strings in prb and then

Flatten[StringCases[Flatten[prb], "https://www.youtube.com" ~~ __]]
POSTED BY: Bill Simpson
Posted 10 years ago

Thank you for the screenshot showing the input and the error message. That allows me to diagnose exactly what the problem is.

Look in your screenshot at the end of the fifth line. See that line ends with }, ,

That is a closing brace and two commas with no string between those commas.

Look at my previously posted solution which began with "Remove the extra comma you have between two strings in prb and then..."

Try doing that and my solution should then work.

If you cannot have a list of strings without extra commas then you may need to find a way to write a line of code to eliminate any Null items from your list of strings. Perhaps DeleteCases might help with that.

POSTED BY: Bill Simpson
Posted 10 years ago

Bill thank you very much for your help, but when I run those lines of code that your I've shared I get the following error

Error message.

that think you that this error is due?

have any other way of doing it? Thank you for supporting me to resolve this, greetings

Luis Ledesma

POSTED BY: Luis Ledesma
Posted 10 years ago

After trying to make some arrangements in the list published without obtaining the desired success I note that I copying evil that piece of list, but to execute the instructions that you shared, in my original list I got what I wanted to, many thanks for your help I have no words to thank you, here I leave a picture so you can see our success, greetings

!success

POSTED BY: Luis Ledesma
Posted 10 years ago

After trying to make some arrangements in the list published without obtaining the desired success I note that I copying evil that piece of list, but to execute the instructions that you shared, in my original list I got what I wanted to, many thanks for your help I have no words to thank you, here I leave a picture so you can see our success, greetings

!success

POSTED BY: Luis Ledesma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract