django 'urlize' strings form text just like twitter

Posted by dana on Stack Overflow See other posts from Stack Overflow or by dana
Published on 2010-05-23T15:40:42Z Indexed on 2010/05/23 16:10 UTC
Read the original article Hit count: 291

Filed under:
|
|
|
|

heyy there

i want to parse a text,let's name it 'post', and 'urlize' some strings if they contain a particular character, in a particular position.

my 'pseudocode' trial would look like that:

 def urlize(post)
      for string in post
      if string icontains ('#')
      url=(r'^searchn/$',
                    searchn,
                    name='news_searchn'),
     then apply url to the string
     return urlize(post)

i want the function to return to me the post with the urlized strings, where necessary (just like twitter does).

i don't understand: how can i parse a text, and search for certain strings? is there ok to make a function especially for 'urlizing' some strings? The function should return the entire post, no matter if it has such kind of strings. is there another way Django offers? Thank you

© Stack Overflow or respective owner

Related posts about django

Related posts about url