Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery regex in string (text and image)
    primarykey
    data
    text
    <p>I need need 2 things in jQuery (twitter like)</p> <ol> <li>regex a normal link</li> <li>check if the link is an image or an website/doc/etc (so i can use a lightbox or something).</li> </ol> <p>for example i have the following text from a json object:</p> <blockquote> <p>Hi i created this <a href="http://flicker.com/image" rel="nofollow">http://flicker.com/image</a> and i went to <a href="http://www.google.com" rel="nofollow">http://www.google.com</a> #home #alone</p> </blockquote> <ol> <li>the link must be checked if the content is an image</li> <li>the A element must be added.</li> <li>the hashtag '#' must also be linked.</li> </ol> <p>I have a little knowledge about jQuery and i edited/created the following script (maybe not nice but at this moment it is working)</p> <pre><code>var username='yourname'; // set user name var format='json'; // set format, you really don't have an option on this one var url='http://api.twitter.com/1/statuses/user_timeline/'+username+'.'+format+'?callback=?'; // make the url var count = 0; // Start from 0 var maxTweet = 10; // Maximum tweets (max limit is 15) $.getJSON(url,function(tweet){ // get the tweets $.each( tweet, function(i, l){ var month1 = {}; // building my month array month1['Jan'] = '01'; month1['Feb'] = '02'; month1['Mar'] = '03'; month1['Apr'] = '04'; month1['May'] = '05'; month1['Jun'] = '06'; month1['Jul'] = '07'; month1['Aug'] = '08'; month1['Sep'] = '09'; month1['Oct'] = '10'; month1['Nov'] = '11'; month1['Dec'] = '12'; var d = tweet[count].created_at; // getting date var d = d.split(" "); // Splitting date var e = tweet[count].created_at.split(" "); // Splitting date var a = d[1]; // Month var month = month1[a]; // still month var d = d[5] + '-' + month + '-' + d[2] + 'T' + d[3] + 'Z' + d[4]; // date like 30-05-2011T13:45:45Z+1000 var date = prettyDate(d); // using prettyDate founded on the Web if(count &lt; maxTweet){ if(date = 'undefined'){ var date = e[2] + '-' + month + '-' + e[5] + ' om ' + e[3]; } // if it is out of range $("#twitter .slides_container").append('&lt;p&gt; &lt;a href="http://twitter.com/#!/' + tweet[count].user.name + '" target="_blank"&gt;&lt;img src="' + tweet[count].user.profile_image_url + '" alt="' + tweet[count].user.name + '" class="twitpic"&gt;&lt;/a&gt; ' + tweet[count].text + '&lt;br /&gt;&lt;em&gt;' + date + '&lt;/em&gt;&lt;/p&gt;') } }); count++; }); </code></pre> <p>tweet[count].text = where i need the regex</p> <p>edited (count++;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload