# -*- coding: utf-8 -*-
import re
from django import forms


class ValidRegexField(forms.CharField):

    def clean(self, value):
        value = super(ValidRegexField, self).clean(value)
        if value:
            try:
                re.compile(value)
            except re.error as e:
                raise forms.ValidationError('Please input valid regexp: %s' % e)
        return value

# -*- coding: utf-8 -*-
import re
from django import forms


class ValidRegexField(forms.CharField):

    def clean(self, value):
        value = super(ValidRegexField, self).clean(value)
        if value:
            try:
                re.compile(value)
            except re.error, e:
                raise forms.ValidationError('Please input valid regexp: %s' % e)
        return value

Fix syntax error for python 2.5
Fix syntax error for python 2.5
