fork download
  1. import re
  2. subject = """These concepts are represented by simple Python classes.
  3. Edit the polls/models.py file so it looks like this:
  4.  
  5. [code]
  6. from django.db import models
  7.  
  8. class Question(models.Model):
  9. question_text = models.CharField(max_length=200)
  10. pub_date = models.DateTimeField('date published')
  11. [/code]"""
  12.  
  13. regex = re.compile(r'(?s)\[code\].*?\[/code\]|(\n)')
  14. def myreplacement(m):
  15. if m.group(1):
  16. return "<br />"
  17. else:
  18. return m.group(0)
  19. replaced = regex.sub(myreplacement, subject)
  20. print(replaced)
  21.  
Success #stdin #stdout 0.01s 7896KB
stdin
Standard input is empty
stdout
These concepts are represented by simple Python classes.  <br >Edit the polls/models.py file so it looks like this: <br ><br >[code]  
from django.db import models

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published') 
[/code]