On Jun 29, 10:05 am, Joru <avenp...@gmail.com> wrote: > I still can't solve this > Anyone had answer on this? > > On Jun 26, 7:39 pm, Joru <avenp...@gmail.com> wrote: > > > Hi, > > > I experience some weirdness regarding usingregexwith django > > I have following function in utils.py > > > from django.utils.text import wrap > > import re > > > str = "wr: \n one bunny \n two bunny \n wr: three bunny \n > > def do_regex(text): > > lines = wrap(text, 55).split('\n') > > for i, line in enumerate(lines): > > cmp = re.compile(r'[wr:]$') > > rgx = cmp.search(line) > > if rgx: > > line = "+%s" % line > > lines[i] = line > > else : > > lines[i] = ">%s" % line > > return '\n'.join(lines) > > do_regex(str) > > > when calling do_regex() from views.py, I always get rgx null while > > when I use django shell rgx will have value when match toregexthat I > > declare in cmp var > > How to fix myregexso it can work inside views.py?
I copied and pasted your code (with an added speech mark to close str) into a controller function, and it works for me: Django version 1.1 beta 1, using settings 'pilchard.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. >wr: > one bunny > two bunny > wr: three bunny > [29/Jun/2009 10:29:45] "GET / HTTP/1.1" 200 2285 What do you mean by "get rgx null"? What exactly is null? Where? James --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---